Skip to content

Commit

Permalink
Ref #84: add a confirmation before running the build and a parameter …
Browse files Browse the repository at this point in the history
…to bypass it.

Change-Id: I6ae9eefaca990b57ead71f667904bd66a576f113
  • Loading branch information
Edouard Cunibil committed Feb 25, 2022
1 parent b17ebdf commit bd832cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bin/combawa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CONFIG_DIR="$COMBAWA_ROOT/config"
COMBAWA_SCRIPTS_DIR="$COMBAWA_ROOT/scripts/combawa"

# State variables.
_COMBAWA_BYPASS_CONFIRMATION=0
_COMBAWA_ONLY_PREDEPLOY=0
_COMBAWA_ONLY_POSTDEPLOY=0
_COMBAWA_NO_PREDEPLOY=0
Expand Down Expand Up @@ -101,6 +102,9 @@ do
shift
else
case $key in
-y | --yes)
_COMBAWA_BYPASS_CONFIRMATION=1
;;
-e | --env)
case $2 in
dev|testing|prod)
Expand Down Expand Up @@ -243,6 +247,18 @@ else
echo -e "$USAGE"
fi

if [[ $_COMBAWA_BYPASS_CONFIRMATION == 0 ]]; then
#################################
section_separator
#################################

message_step "Confirmation:"
read -p "Are you sure that you want to run this build [yN]? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
fi

#################################
section_separator
#################################
Expand Down
2 changes: 2 additions & 0 deletions utils/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ usage()
echo -e "${bold}\t--only-predeploy:${normal} Only process predeploy actions."
echo -e "${bold}\t--only-postdeploy:${normal} Only process postdeploy actions."
echo ''
echo -e "${bold}\t--yes, -y: Bypass confirmation step.${normal}"
echo ''
echo -e "${bold}\t--backup, -b: Generates a backup before building the project.${normal}"
echo -e '\t\tAllowed values are: 0: does not generate a backup, 1: generates a backup.'
echo -e '\t\tDefault value: 1'
Expand Down

0 comments on commit bd832cc

Please sign in to comment.