Add initial CLI parsing for secret deletion

This commit is contained in:
Luke Murphy 2020-10-30 00:32:03 +01:00
parent 26b994ab84
commit dbfe6f8097
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

158
abra
View File

@ -25,6 +25,7 @@ Usage:
abra [options] app <domain> secret auto
abra [options] app <domain> secret generate <secret> <version> [<cmd>]
abra [options] app <domain> secret insert <secret> <version> <data>
abra [options] app <domain> secret (delete|rm) [<secret>] [--all] [--pass] [--force]
abra [options] server add <host> [<user>] [<port>]
abra [options] server (list|ls)
abra [options] server rm <host>
@ -141,75 +142,79 @@ 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() {
printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() {
[[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() {
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1281}
usage=${DOC:40:973}; digest=6d7dd; shorts=(-h -v -e -s '' '' '' '' '')
longs=(--help --version --env --stack --server --domain --pass --force --user)
argcounts=(0 0 1 1 1 1 0 0 1); node_0(){ switch __help 0; }; node_1(){
switch __version 1; }; node_2(){ value __env 2; }; node_3(){ value __stack 3; }
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1368}
usage=${DOC:40:1060}; digest=28b2a; shorts=(-h -e -s -v '' '' '' '' '' '')
longs=(--help --env --stack --version --server --domain --pass --force --user --all)
argcounts=(0 1 1 0 1 1 0 0 1 0); node_0(){ switch __help 0; }; node_1(){
value __env 1; }; node_2(){ value __stack 2; }; node_3(){ switch __version 3; }
node_4(){ value __server 4; }; node_5(){ value __domain 5; }; node_6(){
switch __pass 6; }; node_7(){ switch __force 7; }; node_8(){ value __user 8; }
node_9(){ value _app_ a; }; node_10(){ value _domain_ a; }; node_11(){
value _service_ a; }; node_12(){ value _src_ a; }; node_13(){ value _dst_ a; }
node_14(){ value _args_ a true; }; node_15(){ value _secret_ a; }; node_16(){
value _version_ a; }; node_17(){ value _cmd_ a; }; node_18(){ value _data_ a; }
node_19(){ value _host_ a; }; node_20(){ value _user_ a; }; node_21(){
value _port_ a; }; node_22(){ value _command_ a; }; node_23(){ _command app; }
node_24(){ _command new; }; node_25(){ _command list; }; node_26(){ _command ls
}; node_27(){ _command deploy; }; node_28(){ _command undeploy; }; node_29(){
_command config; }; node_30(){ _command delete; }; node_31(){ _command rm; }
node_32(){ _command logs; }; node_33(){ _command multilogs; }; node_34(){
_command cp; }; node_35(){ _command run; }; node_36(){ _command secret; }
node_37(){ _command auto; }; node_38(){ _command generate; }; node_39(){
_command insert; }; node_40(){ _command server; }; node_41(){ _command add; }
node_42(){ _command use; }; node_43(){ _command init; }; node_44(){
_command upgrade; }; node_45(){ optional 0 1 2 3; }; node_46(){ optional 45; }
node_47(){ optional 4 5 6; }; node_48(){ required 46 23 24 47 9; }; node_49(){
either 25 26; }; node_50(){ required 49; }; node_51(){ required 46 23 50; }
node_52(){ required 46 23 10 27; }; node_53(){ required 46 23 10 28; }
node_54(){ required 46 23 10 29; }; node_55(){ either 30 31; }; node_56(){
required 55; }; node_57(){ optional 7; }; node_58(){ required 46 23 10 56 57; }
node_59(){ optional 11; }; node_60(){ required 46 23 10 32 59; }; node_61(){
required 46 23 10 33; }; node_62(){ required 46 23 10 34 12 13; }; node_63(){
optional 8; }; node_64(){ oneormore 14; }; node_65(){
required 46 23 10 35 63 11 64; }; node_66(){ required 46 23 10 35 11 64; }
node_67(){ required 46 23 10 36 37; }; node_68(){ optional 17; }; node_69(){
required 46 23 10 36 38 15 16 68; }; node_70(){ required 46 23 10 36 39 15 16 18
}; node_71(){ optional 20; }; node_72(){ optional 21; }; node_73(){
required 46 40 41 19 71 72; }; node_74(){ required 46 40 50; }; node_75(){
required 46 40 31 19; }; node_76(){ required 46 40 42 19; }; node_77(){
required 46 40 43 19; }; node_78(){ required 46 44; }; node_79(){
required 46 22 64; }; node_80(){
either 48 51 52 53 54 58 60 61 62 65 66 67 69 70 73 74 75 76 77 78 79; }
node_81(){ required 80; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:973}" >&2; exit 1
}'; unset var___help var___version var___env var___stack var___server \
var___domain var___pass 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_deploy var_undeploy var_config 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_init var_upgrade; parse 81 "$@"
local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__help" \
"${prefix}__version" "${prefix}__env" "${prefix}__stack" "${prefix}__server" \
node_9(){ switch __all 9; }; node_10(){ value _app_ a; }; node_11(){
value _domain_ a; }; node_12(){ value _service_ a; }; node_13(){ value _src_ a
}; node_14(){ value _dst_ a; }; node_15(){ value _args_ a true; }; node_16(){
value _secret_ a; }; node_17(){ value _version_ a; }; node_18(){ value _cmd_ a
}; node_19(){ value _data_ a; }; node_20(){ value _host_ a; }; node_21(){
value _user_ a; }; node_22(){ value _port_ a; }; node_23(){ value _command_ a; }
node_24(){ _command app; }; node_25(){ _command new; }; node_26(){ _command list
}; node_27(){ _command ls; }; node_28(){ _command deploy; }; node_29(){
_command undeploy; }; node_30(){ _command config; }; node_31(){ _command delete
}; node_32(){ _command rm; }; node_33(){ _command logs; }; node_34(){
_command multilogs; }; node_35(){ _command cp; }; node_36(){ _command run; }
node_37(){ _command secret; }; node_38(){ _command auto; }; node_39(){
_command generate; }; node_40(){ _command insert; }; node_41(){ _command server
}; node_42(){ _command add; }; node_43(){ _command use; }; node_44(){
_command init; }; node_45(){ _command upgrade; }; node_46(){ optional 0 1 2 3; }
node_47(){ optional 46; }; node_48(){ optional 4 5 6; }; node_49(){
required 47 24 25 48 10; }; node_50(){ either 26 27; }; node_51(){ required 50
}; node_52(){ required 47 24 51; }; node_53(){ required 47 24 11 28; }
node_54(){ required 47 24 11 29; }; node_55(){ required 47 24 11 30; }
node_56(){ either 31 32; }; node_57(){ required 56; }; node_58(){ optional 7; }
node_59(){ required 47 24 11 57 58; }; node_60(){ optional 12; }; node_61(){
required 47 24 11 33 60; }; node_62(){ required 47 24 11 34; }; node_63(){
required 47 24 11 35 13 14; }; node_64(){ optional 8; }; node_65(){ oneormore 15
}; node_66(){ required 47 24 11 36 64 12 65; }; node_67(){
required 47 24 11 36 12 65; }; node_68(){ required 47 24 11 37 38; }; node_69(){
optional 18; }; node_70(){ required 47 24 11 37 39 16 17 69; }; node_71(){
required 47 24 11 37 40 16 17 19; }; node_72(){ optional 16; }; node_73(){
optional 9; }; node_74(){ optional 6; }; node_75(){
required 47 24 11 37 57 72 73 74 58; }; node_76(){ optional 21; }; node_77(){
optional 22; }; node_78(){ required 47 41 42 20 76 77; }; node_79(){
required 47 41 51; }; node_80(){ required 47 41 32 20; }; node_81(){
required 47 41 43 20; }; node_82(){ required 47 41 44 20; }; node_83(){
required 47 45; }; node_84(){ required 47 23 65; }; node_85(){
either 49 52 53 54 55 59 61 62 63 66 67 68 70 71 75 78 79 80 81 82 83 84; }
node_86(){ required 85; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1060}" >&2
exit 1; }'; unset var___help var___env var___stack var___version var___server \
var___domain var___pass var___force var___user var___all 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_deploy var_undeploy \
var_config 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_init var_upgrade
parse 86 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__help" \
"${prefix}__env" "${prefix}__stack" "${prefix}__version" "${prefix}__server" \
"${prefix}__domain" "${prefix}__pass" "${prefix}__force" "${prefix}__user" \
"${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" \
"${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" \
"${prefix}_cmd_" "${prefix}_data_" "${prefix}_host_" "${prefix}_user_" \
"${prefix}_port_" "${prefix}_command_" "${prefix}app" "${prefix}new" \
"${prefix}list" "${prefix}ls" "${prefix}deploy" "${prefix}undeploy" \
"${prefix}config" "${prefix}delete" "${prefix}rm" "${prefix}logs" \
"${prefix}multilogs" "${prefix}cp" "${prefix}run" "${prefix}secret" \
"${prefix}auto" "${prefix}generate" "${prefix}insert" "${prefix}server" \
"${prefix}add" "${prefix}use" "${prefix}init" "${prefix}upgrade"
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__version=${var___version:-false}'
"${prefix}__all" "${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" \
"${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" \
"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_host_" \
"${prefix}_user_" "${prefix}_port_" "${prefix}_command_" "${prefix}app" \
"${prefix}new" "${prefix}list" "${prefix}ls" "${prefix}deploy" \
"${prefix}undeploy" "${prefix}config" "${prefix}delete" "${prefix}rm" \
"${prefix}logs" "${prefix}multilogs" "${prefix}cp" "${prefix}run" \
"${prefix}secret" "${prefix}auto" "${prefix}generate" "${prefix}insert" \
"${prefix}server" "${prefix}add" "${prefix}use" "${prefix}init" \
"${prefix}upgrade"; eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__version=${var___version:-false}'
eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__domain=${var___domain:-}'
eval "${prefix}"'__pass=${var___pass:-false}'
eval "${prefix}"'__force=${var___force:-false}'
eval "${prefix}"'__user=${var___user:-}'; eval "${prefix}"'_app_=${var__app_:-}'
eval "${prefix}"'__user=${var___user:-}'
eval "${prefix}"'__all=${var___all:-false}'
eval "${prefix}"'_app_=${var__app_:-}'
eval "${prefix}"'_domain_=${var__domain_:-}'
eval "${prefix}"'_service_=${var__service_:-}'
eval "${prefix}"'_src_=${var__src_:-}'; eval "${prefix}"'_dst_=${var__dst_:-}'
@ -240,18 +245,18 @@ eval "${prefix}"'add=${var_add:-false}'; eval "${prefix}"'use=${var_use:-false}'
eval "${prefix}"'init=${var_init:-false}'
eval "${prefix}"'upgrade=${var_upgrade:-false}'; local docopt_i=1
[[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do
declare -p "${prefix}__help" "${prefix}__version" "${prefix}__env" \
"${prefix}__stack" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \
"${prefix}__force" "${prefix}__user" "${prefix}_app_" "${prefix}_domain_" \
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" \
"${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \
"${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_command_" \
"${prefix}app" "${prefix}new" "${prefix}list" "${prefix}ls" "${prefix}deploy" \
"${prefix}undeploy" "${prefix}config" "${prefix}delete" "${prefix}rm" \
"${prefix}logs" "${prefix}multilogs" "${prefix}cp" "${prefix}run" \
"${prefix}secret" "${prefix}auto" "${prefix}generate" "${prefix}insert" \
"${prefix}server" "${prefix}add" "${prefix}use" "${prefix}init" \
"${prefix}upgrade"; done; }
declare -p "${prefix}__help" "${prefix}__env" "${prefix}__stack" \
"${prefix}__version" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \
"${prefix}__force" "${prefix}__user" "${prefix}__all" "${prefix}_app_" \
"${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" \
"${prefix}_data_" "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" \
"${prefix}_command_" "${prefix}app" "${prefix}new" "${prefix}list" \
"${prefix}ls" "${prefix}deploy" "${prefix}undeploy" "${prefix}config" \
"${prefix}delete" "${prefix}rm" "${prefix}logs" "${prefix}multilogs" \
"${prefix}cp" "${prefix}run" "${prefix}secret" "${prefix}auto" \
"${prefix}generate" "${prefix}insert" "${prefix}server" "${prefix}add" \
"${prefix}use" "${prefix}init" "${prefix}upgrade"; done; }
# docopt parser above, complete command for generating this parser is `docopt.sh abra`
PROGRAM_NAME=$(basename "$0")
@ -582,6 +587,15 @@ sub_app_secret_insert() {
fi
}
###### .. app <domain> secret delete
sub_app_secret_delete(){
sub_app_secret_rm
}
sub_app_secret_rm(){
echo "TODO"
}
###### .. app <domain> secret generate
sub_app_secret_generate(){
load_instance