Add --force option to app .. delete

This commit is contained in:
3wc 2020-10-28 01:52:27 +02:00
parent 8d139d4d28
commit 8909a46d8c

145
abra
View File

@ -15,7 +15,7 @@ Usage:
abra [options] app (list|ls) abra [options] app (list|ls)
abra [options] app <domain> deploy abra [options] app <domain> deploy
abra [options] app <domain> undeploy abra [options] app <domain> undeploy
abra [options] app <domain> (delete|rm) abra [options] app <domain> (delete|rm) [--force]
abra [options] app <domain> logs [<service>] abra [options] app <domain> logs [<service>]
abra [options] app <domain> multilogs abra [options] app <domain> multilogs
abra [options] app <domain> cp <src> <dst> abra [options] app <domain> cp <src> <dst>
@ -140,68 +140,71 @@ eval "var_$1+=($value)"; else eval "var_$1=$value"; fi; return 0; fi; done
return 1; }; stdout() { printf -- "cat <<'EOM'\n%s\nEOM\n" "$1"; }; stderr() { return 1; }; stdout() { printf -- "cat <<'EOM'\n%s\nEOM\n" "$1"; }; stderr() {
printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() { printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() {
[[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() { [[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() {
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1227} printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1237}
usage=${DOC:40:919}; digest=40db2; shorts=(-s -e -v -h '' '' '') usage=${DOC:40:929}; digest=03087; shorts=(-h -s -e -v '' '' '' '')
longs=(--stack --env --version --help --server --domain --user) longs=(--help --stack --env --version --server --domain --force --user)
argcounts=(1 1 0 0 1 1 1); node_0(){ value __stack 0; }; node_1(){ value __env 1 argcounts=(0 1 1 0 1 1 0 1); node_0(){ switch __help 0; }; node_1(){
}; node_2(){ switch __version 2; }; node_3(){ switch __help 3; }; node_4(){ value __stack 1; }; node_2(){ value __env 2; }; node_3(){ switch __version 3; }
value __server 4; }; node_5(){ value __domain 5; }; node_6(){ value __user 6; } node_4(){ value __server 4; }; node_5(){ value __domain 5; }; node_6(){
node_7(){ value _app_ a; }; node_8(){ value _domain_ a; }; node_9(){ switch __force 6; }; node_7(){ value __user 7; }; node_8(){ value _app_ a; }
value _service_ a; }; node_10(){ value _src_ a; }; node_11(){ value _dst_ a; } node_9(){ value _domain_ a; }; node_10(){ value _service_ a; }; node_11(){
node_12(){ value _args_ a true; }; node_13(){ value _secret_ a; }; node_14(){ value _src_ a; }; node_12(){ value _dst_ a; }; node_13(){ value _args_ a true; }
value _version_ a; }; node_15(){ value _cmd_ a; }; node_16(){ value _data_ a; } node_14(){ value _secret_ a; }; node_15(){ value _version_ a; }; node_16(){
node_17(){ value _host_ a; }; node_18(){ value _user_ a; }; node_19(){ value _cmd_ a; }; node_17(){ value _data_ a; }; node_18(){ value _host_ a; }
value _port_ a; }; node_20(){ value _command_ a; }; node_21(){ _command app; } node_19(){ value _user_ a; }; node_20(){ value _port_ a; }; node_21(){
node_22(){ _command new; }; node_23(){ _command list; }; node_24(){ _command ls value _command_ a; }; node_22(){ _command app; }; node_23(){ _command new; }
}; node_25(){ _command deploy; }; node_26(){ _command undeploy; }; node_27(){ node_24(){ _command list; }; node_25(){ _command ls; }; node_26(){
_command delete; }; node_28(){ _command rm; }; node_29(){ _command logs; } _command deploy; }; node_27(){ _command undeploy; }; node_28(){ _command delete
node_30(){ _command multilogs; }; node_31(){ _command cp; }; node_32(){ }; node_29(){ _command rm; }; node_30(){ _command logs; }; node_31(){
_command run; }; node_33(){ _command secret; }; node_34(){ _command auto; } _command multilogs; }; node_32(){ _command cp; }; node_33(){ _command run; }
node_35(){ _command generate; }; node_36(){ _command insert; }; node_37(){ node_34(){ _command secret; }; node_35(){ _command auto; }; node_36(){
_command server; }; node_38(){ _command add; }; node_39(){ _command use; } _command generate; }; node_37(){ _command insert; }; node_38(){ _command server
node_40(){ _command init; }; node_41(){ _command upgrade; }; node_42(){ }; node_39(){ _command add; }; node_40(){ _command use; }; node_41(){
optional 0 1 2 3; }; node_43(){ optional 42; }; node_44(){ optional 4 5; } _command init; }; node_42(){ _command upgrade; }; node_43(){ optional 0 1 2 3; }
node_45(){ required 43 21 22 44 7; }; node_46(){ either 23 24; }; node_47(){ node_44(){ optional 43; }; node_45(){ optional 4 5; }; node_46(){
required 46; }; node_48(){ required 43 21 47; }; node_49(){ required 43 21 8 25 required 44 22 23 45 8; }; node_47(){ either 24 25; }; node_48(){ required 47; }
}; node_50(){ required 43 21 8 26; }; node_51(){ either 27 28; }; node_52(){ node_49(){ required 44 22 48; }; node_50(){ required 44 22 9 26; }; node_51(){
required 51; }; node_53(){ required 43 21 8 52; }; node_54(){ optional 9; } required 44 22 9 27; }; node_52(){ either 28 29; }; node_53(){ required 52; }
node_55(){ required 43 21 8 29 54; }; node_56(){ required 43 21 8 30; } node_54(){ optional 6; }; node_55(){ required 44 22 9 53 54; }; node_56(){
node_57(){ required 43 21 8 31 10 11; }; node_58(){ optional 6; }; node_59(){ optional 10; }; node_57(){ required 44 22 9 30 56; }; node_58(){
oneormore 12; }; node_60(){ required 43 21 8 32 58 9 59; }; node_61(){ required 44 22 9 31; }; node_59(){ required 44 22 9 32 11 12; }; node_60(){
required 43 21 8 32 9 59; }; node_62(){ required 43 21 8 33 34; }; node_63(){ optional 7; }; node_61(){ oneormore 13; }; node_62(){
optional 15; }; node_64(){ required 43 21 8 33 35 13 14 63; }; node_65(){ required 44 22 9 33 60 10 61; }; node_63(){ required 44 22 9 33 10 61; }
required 43 21 8 33 36 13 14 16; }; node_66(){ optional 18; }; node_67(){ node_64(){ required 44 22 9 34 35; }; node_65(){ optional 16; }; node_66(){
optional 19; }; node_68(){ required 43 37 38 17 66 67; }; node_69(){ required 44 22 9 34 36 14 15 65; }; node_67(){ required 44 22 9 34 37 14 15 17
required 43 37 47; }; node_70(){ required 43 37 28 17; }; node_71(){ }; node_68(){ optional 19; }; node_69(){ optional 20; }; node_70(){
required 43 37 39 17; }; node_72(){ required 43 37 40 17; }; node_73(){ required 44 38 39 18 68 69; }; node_71(){ required 44 38 48; }; node_72(){
required 43 41; }; node_74(){ required 43 20 59; }; node_75(){ required 44 38 29 18; }; node_73(){ required 44 38 40 18; }; node_74(){
either 45 48 49 50 53 55 56 57 60 61 62 64 65 68 69 70 71 72 73 74; } required 44 38 41 18; }; node_75(){ required 44 42; }; node_76(){
node_76(){ required 75; }; cat <<<' docopt_exit() { required 44 21 61; }; node_77(){
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:919}" >&2; exit 1 either 46 49 50 51 55 57 58 59 62 63 64 66 67 70 71 72 73 74 75 76; }
}'; unset var___stack var___env var___version var___help var___server \ node_78(){ required 77; }; cat <<<' docopt_exit() {
var___domain var___user var__app_ var__domain_ var__service_ var__src_ \ [[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:929}" >&2; exit 1
var__dst_ var__args_ var__secret_ var__version_ var__cmd_ var__data_ \ }'; unset var___help var___stack var___env var___version var___server \
var___domain var___force var___user var__app_ var__domain_ var__service_ \
var__src_ var__dst_ var__args_ var__secret_ var__version_ var__cmd_ var__data_ \
var__host_ var__user_ var__port_ var__command_ var_app var_new var_list var_ls \ var__host_ var__user_ var__port_ var__command_ var_app var_new var_list var_ls \
var_deploy var_undeploy var_delete var_rm var_logs var_multilogs var_cp \ var_deploy var_undeploy var_delete var_rm var_logs var_multilogs var_cp \
var_run var_secret var_auto var_generate var_insert var_server var_add var_use \ var_run var_secret var_auto var_generate var_insert var_server var_add var_use \
var_init var_upgrade; parse 76 "$@"; local prefix=${DOCOPT_PREFIX:-''} var_init var_upgrade; parse 78 "$@"; local prefix=${DOCOPT_PREFIX:-''}
unset "${prefix}__stack" "${prefix}__env" "${prefix}__version" \ unset "${prefix}__help" "${prefix}__stack" "${prefix}__env" \
"${prefix}__help" "${prefix}__server" "${prefix}__domain" "${prefix}__user" \ "${prefix}__version" "${prefix}__server" "${prefix}__domain" \
"${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}__force" "${prefix}__user" "${prefix}_app_" "${prefix}_domain_" \
"${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" \ "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" \
"${prefix}_cmd_" "${prefix}_data_" "${prefix}_host_" "${prefix}_user_" \ "${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \
"${prefix}_port_" "${prefix}_command_" "${prefix}app" "${prefix}new" \ "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_command_" \
"${prefix}list" "${prefix}ls" "${prefix}deploy" "${prefix}undeploy" \ "${prefix}app" "${prefix}new" "${prefix}list" "${prefix}ls" "${prefix}deploy" \
"${prefix}delete" "${prefix}rm" "${prefix}logs" "${prefix}multilogs" \ "${prefix}undeploy" "${prefix}delete" "${prefix}rm" "${prefix}logs" \
"${prefix}cp" "${prefix}run" "${prefix}secret" "${prefix}auto" \ "${prefix}multilogs" "${prefix}cp" "${prefix}run" "${prefix}secret" \
"${prefix}generate" "${prefix}insert" "${prefix}server" "${prefix}add" \ "${prefix}auto" "${prefix}generate" "${prefix}insert" "${prefix}server" \
"${prefix}use" "${prefix}init" "${prefix}upgrade" "${prefix}add" "${prefix}use" "${prefix}init" "${prefix}upgrade"
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__stack=${var___stack:-}' eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__env=${var___env:-}' eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__version=${var___version:-false}' eval "${prefix}"'__version=${var___version:-false}'
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__server=${var___server:-}' eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__domain=${var___domain:-}' eval "${prefix}"'__domain=${var___domain:-}'
eval "${prefix}"'__force=${var___force:-false}'
eval "${prefix}"'__user=${var___user:-}'; eval "${prefix}"'_app_=${var__app_:-}' eval "${prefix}"'__user=${var___user:-}'; eval "${prefix}"'_app_=${var__app_:-}'
eval "${prefix}"'_domain_=${var__domain_:-}' eval "${prefix}"'_domain_=${var__domain_:-}'
eval "${prefix}"'_service_=${var__service_:-}' eval "${prefix}"'_service_=${var__service_:-}'
@ -232,17 +235,17 @@ eval "${prefix}"'add=${var_add:-false}'; eval "${prefix}"'use=${var_use:-false}'
eval "${prefix}"'init=${var_init:-false}' eval "${prefix}"'init=${var_init:-false}'
eval "${prefix}"'upgrade=${var_upgrade:-false}'; local docopt_i=1 eval "${prefix}"'upgrade=${var_upgrade:-false}'; local docopt_i=1
[[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do [[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do
declare -p "${prefix}__stack" "${prefix}__env" "${prefix}__version" \ declare -p "${prefix}__help" "${prefix}__stack" "${prefix}__env" \
"${prefix}__help" "${prefix}__server" "${prefix}__domain" "${prefix}__user" \ "${prefix}__version" "${prefix}__server" "${prefix}__domain" \
"${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}__force" "${prefix}__user" "${prefix}_app_" "${prefix}_domain_" \
"${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" \ "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" \
"${prefix}_cmd_" "${prefix}_data_" "${prefix}_host_" "${prefix}_user_" \ "${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \
"${prefix}_port_" "${prefix}_command_" "${prefix}app" "${prefix}new" \ "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_command_" \
"${prefix}list" "${prefix}ls" "${prefix}deploy" "${prefix}undeploy" \ "${prefix}app" "${prefix}new" "${prefix}list" "${prefix}ls" "${prefix}deploy" \
"${prefix}delete" "${prefix}rm" "${prefix}logs" "${prefix}multilogs" \ "${prefix}undeploy" "${prefix}delete" "${prefix}rm" "${prefix}logs" \
"${prefix}cp" "${prefix}run" "${prefix}secret" "${prefix}auto" \ "${prefix}multilogs" "${prefix}cp" "${prefix}run" "${prefix}secret" \
"${prefix}generate" "${prefix}insert" "${prefix}server" "${prefix}add" \ "${prefix}auto" "${prefix}generate" "${prefix}insert" "${prefix}server" \
"${prefix}use" "${prefix}init" "${prefix}upgrade"; done; } "${prefix}add" "${prefix}use" "${prefix}init" "${prefix}upgrade"; done; }
# docopt parser above, complete command for generating this parser is `docopt.sh abra` # docopt parser above, complete command for generating this parser is `docopt.sh abra`
PROGRAM_NAME=$(basename "$0") PROGRAM_NAME=$(basename "$0")
@ -518,7 +521,7 @@ sub_app_undeploy (){
load_instance_env load_instance_env
warning "Un-deploy $DOMAIN from $SERVER?" warning "Un-deploy $DOMAIN from $SERVER?"
read -rp "Enter to continue, Ctrl+C to quit" read -rp "Enter to continue, Ctrl+C to quit"
docker stack rm "$STACK_NAME" docker stack rm "$STACK_NAME"
} }
@ -532,8 +535,10 @@ sub_app_delete (){
load_instance load_instance
load_instance_env load_instance_env
warning "Delete $ENV_FILE?" if [ "$abra___force" != "true" ]; then
read -rp "Enter to continue, Ctrl+C to quit" warning "Delete $ENV_FILE?"
read -rp "Enter to continue, Ctrl+C to quit"
fi
rm "$ENV_FILE" rm "$ENV_FILE"
} }
@ -789,7 +794,7 @@ abra() {
declare abra___stack abra___env abra__command_ abra__args_ \ declare abra___stack abra___env abra__command_ abra__args_ \
abra__secret_ abra__version_ abra__data_ abra___user abra__host_ \ abra__secret_ abra__version_ abra__data_ abra___user abra__host_ \
abra__app_ abra__port_ abra__user_ abra__service_ abra__src_ abra__dst_ \ abra__app_ abra__port_ abra__user_ abra__service_ abra__src_ abra__dst_ \
abra__domain_ abra___server abra___domain abra__domain_ abra___server abra___domain abra___force
DOCOPT_PREFIX=abra_ DOCOPT_PREFIX=abra_
eval "$(docopt "$@")" eval "$(docopt "$@")"