Consistent y/n confirmation prompts

This commit is contained in:
3wc 2020-10-30 20:57:13 +02:00
parent a3cd6d2281
commit b226396764

25
abra
View File

@ -377,6 +377,15 @@ load_context() {
fi fi
} }
prompt_confirm() {
read -rp "Continue? (y/[n])? " choice
case "$choice" in
y|Y ) return ;;
* ) exit;;
esac
}
####################################### #######################################
# abra app .. # abra app ..
####################################### #######################################
@ -506,13 +515,7 @@ sub_app_deploy (){
fi fi
echo " Stack: $(tput setaf 1)${STACK_NAME}$(tput sgr0)" echo " Stack: $(tput setaf 1)${STACK_NAME}$(tput sgr0)"
read -rp "Continue? (y/[n])? " choice prompt_confirm
case "$choice" in
y|Y ) ;;
n|N ) return;;
* ) return;;
esac
( (
cd "$APP_DIR" || error "\$APP_DIR '$APP_DIR' not found" cd "$APP_DIR" || error "\$APP_DIR '$APP_DIR' not found"
@ -535,7 +538,7 @@ sub_app_undeploy (){
load_instance_env load_instance_env
warning "Un-deploy $STACK_NAME from $SERVER?" warning "Un-deploy $STACK_NAME from $SERVER?"
read -rp "Enter to continue, Ctrl+C to quit" prompt_confirm
docker stack rm "$STACK_NAME" docker stack rm "$STACK_NAME"
} }
@ -558,7 +561,7 @@ sub_app_delete (){
if [ "$abra___force" != "true" ]; then if [ "$abra___force" != "true" ]; then
warning "Delete $ENV_FILE?" warning "Delete $ENV_FILE?"
read -rp "Enter to continue, Ctrl+C to quit" prompt_confirm
fi fi
rm "$ENV_FILE" rm "$ENV_FILE"
@ -604,8 +607,8 @@ sub_app_secret_rm(){
fi fi
if [ "$abra___force" != "true" ]; then if [ "$abra___force" != "true" ]; then
warning "Delete $(echo "$NAMES" | paste -d "")?" warning "About to delete $(echo "$NAMES" | paste -d "")"
read -rp "Enter to continue, Ctrl+C to quit" prompt_confirm
fi fi
for NAME in ${NAMES}; do for NAME in ${NAMES}; do