Reënable custom per-stack commands

This commit is contained in:
3wc 2020-12-14 12:33:22 +02:00
parent cb2d563ea0
commit 0d202eedfc

147
abra
View File

@ -28,6 +28,7 @@ Usage:
abra [options] app <domain> secret generate <secret> <version> [<cmd>] [--pass] abra [options] app <domain> secret generate <secret> <version> [<cmd>] [--pass]
abra [options] app <domain> secret insert <secret> <version> <data> [--pass] abra [options] app <domain> secret insert <secret> <version> <data> [--pass]
abra [options] app <domain> secret (delete|rm) (<secret>|--all) [--pass] [--force] abra [options] app <domain> secret (delete|rm) (<secret>|--all) [--pass] [--force]
abra [options] app <domain> <command> [<arg>]
abra [options] server add <host> [<user>] [<port>] abra [options] server add <host> [<user>] [<port>]
abra [options] server (list|ls) abra [options] server (list|ls)
abra [options] server rm <host> abra [options] server rm <host>
@ -143,76 +144,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() { 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:1449} printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1497}
usage=${DOC:40:1141}; digest=2bcee; shorts=(-s -h -e -v '' '' '' '' '' '' '' '') usage=${DOC:40:1189}; digest=feaba; shorts=(-e -v -h -s '' '' '' '' '' '' '' '')
longs=(--stack --help --env --version --server --domain --pass --auto --status --force --user --all) longs=(--env --version --help --stack --server --domain --pass --auto --status --force --user --all)
argcounts=(1 0 1 0 1 1 0 0 0 0 1 0); node_0(){ value __stack 0; }; node_1(){ argcounts=(1 0 0 1 1 1 0 0 0 0 1 0); node_0(){ value __env 0; }; node_1(){
switch __help 1; }; node_2(){ value __env 2; }; node_3(){ switch __version 3; } switch __version 1; }; node_2(){ switch __help 2; }; node_3(){ value __stack 3
node_4(){ value __server 4; }; node_5(){ value __domain 5; }; node_6(){ }; node_4(){ value __server 4; }; node_5(){ value __domain 5; }; node_6(){
switch __pass 6; }; node_7(){ switch __auto 7; }; node_8(){ switch __status 8; } switch __pass 6; }; node_7(){ switch __auto 7; }; node_8(){ switch __status 8; }
node_9(){ switch __force 9; }; node_10(){ value __user 10; }; node_11(){ node_9(){ switch __force 9; }; node_10(){ value __user 10; }; node_11(){
switch __all 11; }; node_12(){ value _app_ a; }; node_13(){ value _domain_ a; } switch __all 11; }; node_12(){ value _app_ a; }; node_13(){ value _domain_ a; }
node_14(){ value _service_ a; }; node_15(){ value _src_ a; }; node_16(){ node_14(){ value _service_ a; }; node_15(){ value _src_ a; }; node_16(){
value _dst_ a; }; node_17(){ value _args_ a true; }; node_18(){ value _secret_ a value _dst_ a; }; node_17(){ value _args_ a true; }; node_18(){ value _secret_ a
}; node_19(){ value _version_ a; }; node_20(){ value _cmd_ a; }; node_21(){ }; node_19(){ value _version_ a; }; node_20(){ value _cmd_ a; }; node_21(){
value _data_ a; }; node_22(){ value _host_ a; }; node_23(){ value _user_ a; } value _data_ a; }; node_22(){ value _command_ a; }; node_23(){ value _arg_ a; }
node_24(){ value _port_ a; }; node_25(){ _command app; }; node_26(){ node_24(){ value _host_ a; }; node_25(){ value _user_ a; }; node_26(){
_command new; }; node_27(){ _command list; }; node_28(){ _command ls; } value _port_ a; }; node_27(){ _command app; }; node_28(){ _command new; }
node_29(){ _command deploy; }; node_30(){ _command undeploy; }; node_31(){ node_29(){ _command list; }; node_30(){ _command ls; }; node_31(){
_command config; }; node_32(){ _command delete; }; node_33(){ _command rm; } _command deploy; }; node_32(){ _command undeploy; }; node_33(){ _command config
node_34(){ _command logs; }; node_35(){ _command multilogs; }; node_36(){ }; node_34(){ _command delete; }; node_35(){ _command rm; }; node_36(){
_command cp; }; node_37(){ _command check; }; node_38(){ _command ps; } _command logs; }; node_37(){ _command multilogs; }; node_38(){ _command cp; }
node_39(){ _command run; }; node_40(){ _command secret; }; node_41(){ node_39(){ _command check; }; node_40(){ _command ps; }; node_41(){ _command run
_command auto; }; node_42(){ _command generate; }; node_43(){ _command insert; } }; node_42(){ _command secret; }; node_43(){ _command auto; }; node_44(){
node_44(){ _command server; }; node_45(){ _command add; }; node_46(){ _command generate; }; node_45(){ _command insert; }; node_46(){ _command server
_command use; }; node_47(){ _command init; }; node_48(){ _command upgrade; } }; node_47(){ _command add; }; node_48(){ _command use; }; node_49(){
node_49(){ optional 0 1 2 3; }; node_50(){ optional 49; }; node_51(){ optional 4 _command init; }; node_50(){ _command upgrade; }; node_51(){ optional 0 1 2 3; }
}; node_52(){ optional 5; }; node_53(){ optional 6; }; node_54(){ optional 7; } node_52(){ optional 51; }; node_53(){ optional 4; }; node_54(){ optional 5; }
node_55(){ required 50 25 26 51 52 53 54 12; }; node_56(){ either 27 28; } node_55(){ optional 6; }; node_56(){ optional 7; }; node_57(){
node_57(){ required 56; }; node_58(){ optional 8; }; node_59(){ required 52 27 28 53 54 55 56 12; }; node_58(){ either 29 30; }; node_59(){
required 50 25 57 58; }; node_60(){ required 50 25 13 29; }; node_61(){ required 58; }; node_60(){ optional 8; }; node_61(){ required 52 27 59 60; }
required 50 25 13 30; }; node_62(){ required 50 25 13 31; }; node_63(){ node_62(){ required 52 27 13 31; }; node_63(){ required 52 27 13 32; }
either 32 33; }; node_64(){ required 63; }; node_65(){ optional 9; }; node_66(){ node_64(){ required 52 27 13 33; }; node_65(){ either 34 35; }; node_66(){
required 50 25 13 64 65; }; node_67(){ optional 14; }; node_68(){ required 65; }; node_67(){ optional 9; }; node_68(){ required 52 27 13 66 67; }
required 50 25 13 34 67; }; node_69(){ required 50 25 13 35; }; node_70(){ node_69(){ optional 14; }; node_70(){ required 52 27 13 36 69; }; node_71(){
required 50 25 13 36 15 16; }; node_71(){ required 50 25 13 37; }; node_72(){ required 52 27 13 37; }; node_72(){ required 52 27 13 38 15 16; }; node_73(){
required 50 25 13 38; }; node_73(){ optional 10; }; node_74(){ oneormore 17; } required 52 27 13 39; }; node_74(){ required 52 27 13 40; }; node_75(){
node_75(){ required 50 25 13 39 73 14 74; }; node_76(){ optional 10; }; node_76(){ oneormore 17; }; node_77(){
required 50 25 13 39 14 74; }; node_77(){ required 50 25 13 40 41 53; } required 52 27 13 41 75 14 76; }; node_78(){ required 52 27 13 41 14 76; }
node_78(){ optional 20; }; node_79(){ required 50 25 13 40 42 18 19 78 53; } node_79(){ required 52 27 13 42 43 55; }; node_80(){ optional 20; }; node_81(){
node_80(){ required 50 25 13 40 43 18 19 21 53; }; node_81(){ either 18 11; } required 52 27 13 42 44 18 19 80 55; }; node_82(){
node_82(){ required 81; }; node_83(){ required 50 25 13 40 64 82 53 65; } required 52 27 13 42 45 18 19 21 55; }; node_83(){ either 18 11; }; node_84(){
node_84(){ optional 23; }; node_85(){ optional 24; }; node_86(){ required 83; }; node_85(){ required 52 27 13 42 66 84 55 67; }; node_86(){
required 50 44 45 22 84 85; }; node_87(){ required 50 44 57; }; node_88(){ optional 23; }; node_87(){ required 52 27 13 22 86; }; node_88(){ optional 25; }
required 50 44 33 22; }; node_89(){ required 50 44 46 22; }; node_90(){ node_89(){ optional 26; }; node_90(){ required 52 46 47 24 88 89; }; node_91(){
required 50 44 47 22; }; node_91(){ required 50 48; }; node_92(){ required 52 46 59; }; node_92(){ required 52 46 35 24; }; node_93(){
either 55 59 60 61 62 66 68 69 70 71 72 75 76 77 79 80 83 86 87 88 89 90 91; } required 52 46 48 24; }; node_94(){ required 52 46 49 24; }; node_95(){
node_93(){ required 92; }; cat <<<' docopt_exit() { required 52 50; }; node_96(){
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1141}" >&2 either 57 61 62 63 64 68 70 71 72 73 74 77 78 79 81 82 85 87 90 91 92 93 94 95
exit 1; }'; unset var___stack var___help var___env var___version var___server \ }; node_97(){ required 96; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1189}" >&2
exit 1; }'; unset var___env var___version var___help var___stack var___server \
var___domain var___pass var___auto var___status var___force var___user \ var___domain var___pass var___auto var___status var___force var___user \
var___all var__app_ var__domain_ var__service_ var__src_ var__dst_ var__args_ \ 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__secret_ var__version_ var__cmd_ var__data_ var__command_ var__arg_ \
var__port_ var_app var_new var_list var_ls var_deploy var_undeploy var_config \ var__host_ var__user_ var__port_ var_app var_new var_list var_ls var_deploy \
var_delete var_rm var_logs var_multilogs var_cp var_check var_ps var_run \ var_undeploy var_config var_delete var_rm var_logs var_multilogs var_cp \
var_secret var_auto var_generate var_insert var_server var_add var_use \ var_check var_ps var_run var_secret var_auto var_generate var_insert \
var_init var_upgrade; parse 93 "$@"; local prefix=${DOCOPT_PREFIX:-''} var_server var_add var_use var_init var_upgrade; parse 97 "$@"
unset "${prefix}__stack" "${prefix}__help" "${prefix}__env" \ local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__env" "${prefix}__version" \
"${prefix}__version" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \ "${prefix}__help" "${prefix}__stack" "${prefix}__server" "${prefix}__domain" \
"${prefix}__auto" "${prefix}__status" "${prefix}__force" "${prefix}__user" \ "${prefix}__pass" "${prefix}__auto" "${prefix}__status" "${prefix}__force" \
"${prefix}__all" "${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" \ "${prefix}__user" "${prefix}__all" "${prefix}_app_" "${prefix}_domain_" \
"${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" \ "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" \
"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_host_" \ "${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \
"${prefix}_user_" "${prefix}_port_" "${prefix}app" "${prefix}new" \ "${prefix}_command_" "${prefix}_arg_" "${prefix}_host_" "${prefix}_user_" \
"${prefix}list" "${prefix}ls" "${prefix}deploy" "${prefix}undeploy" \ "${prefix}_port_" "${prefix}app" "${prefix}new" "${prefix}list" "${prefix}ls" \
"${prefix}config" "${prefix}delete" "${prefix}rm" "${prefix}logs" \ "${prefix}deploy" "${prefix}undeploy" "${prefix}config" "${prefix}delete" \
"${prefix}multilogs" "${prefix}cp" "${prefix}check" "${prefix}ps" \ "${prefix}rm" "${prefix}logs" "${prefix}multilogs" "${prefix}cp" \
"${prefix}run" "${prefix}secret" "${prefix}auto" "${prefix}generate" \ "${prefix}check" "${prefix}ps" "${prefix}run" "${prefix}secret" \
"${prefix}insert" "${prefix}server" "${prefix}add" "${prefix}use" \ "${prefix}auto" "${prefix}generate" "${prefix}insert" "${prefix}server" \
"${prefix}init" "${prefix}upgrade"; eval "${prefix}"'__stack=${var___stack:-}' "${prefix}add" "${prefix}use" "${prefix}init" "${prefix}upgrade"
eval "${prefix}"'__help=${var___help:-false}'
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}"'__stack=${var___stack:-}'
eval "${prefix}"'__server=${var___server:-}' eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__domain=${var___domain:-}' eval "${prefix}"'__domain=${var___domain:-}'
eval "${prefix}"'__pass=${var___pass:-false}' eval "${prefix}"'__pass=${var___pass:-false}'
@ -230,7 +234,8 @@ eval "${prefix}"'_args_=("${var__args_[@]}")'; else eval "${prefix}"'_args_=()'
fi; eval "${prefix}"'_secret_=${var__secret_:-}' fi; eval "${prefix}"'_secret_=${var__secret_:-}'
eval "${prefix}"'_version_=${var__version_:-}' eval "${prefix}"'_version_=${var__version_:-}'
eval "${prefix}"'_cmd_=${var__cmd_:-}'; eval "${prefix}"'_data_=${var__data_:-}' eval "${prefix}"'_cmd_=${var__cmd_:-}'; eval "${prefix}"'_data_=${var__data_:-}'
eval "${prefix}"'_host_=${var__host_:-}' eval "${prefix}"'_command_=${var__command_:-}'
eval "${prefix}"'_arg_=${var__arg_:-}'; eval "${prefix}"'_host_=${var__host_:-}'
eval "${prefix}"'_user_=${var__user_:-}' eval "${prefix}"'_user_=${var__user_:-}'
eval "${prefix}"'_port_=${var__port_:-}' eval "${prefix}"'_port_=${var__port_:-}'
eval "${prefix}"'app=${var_app:-false}'; eval "${prefix}"'new=${var_new:-false}' eval "${prefix}"'app=${var_app:-false}'; eval "${prefix}"'new=${var_new:-false}'
@ -253,19 +258,19 @@ 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}__help" "${prefix}__env" \ declare -p "${prefix}__env" "${prefix}__version" "${prefix}__help" \
"${prefix}__version" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \ "${prefix}__stack" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \
"${prefix}__auto" "${prefix}__status" "${prefix}__force" "${prefix}__user" \ "${prefix}__auto" "${prefix}__status" "${prefix}__force" "${prefix}__user" \
"${prefix}__all" "${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" \ "${prefix}__all" "${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" \
"${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" \ "${prefix}_src_" "${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" \
"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_host_" \ "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \
"${prefix}_user_" "${prefix}_port_" "${prefix}app" "${prefix}new" \ "${prefix}_arg_" "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" \
"${prefix}list" "${prefix}ls" "${prefix}deploy" "${prefix}undeploy" \ "${prefix}app" "${prefix}new" "${prefix}list" "${prefix}ls" "${prefix}deploy" \
"${prefix}config" "${prefix}delete" "${prefix}rm" "${prefix}logs" \ "${prefix}undeploy" "${prefix}config" "${prefix}delete" "${prefix}rm" \
"${prefix}multilogs" "${prefix}cp" "${prefix}check" "${prefix}ps" \ "${prefix}logs" "${prefix}multilogs" "${prefix}cp" "${prefix}check" \
"${prefix}run" "${prefix}secret" "${prefix}auto" "${prefix}generate" \ "${prefix}ps" "${prefix}run" "${prefix}secret" "${prefix}auto" \
"${prefix}insert" "${prefix}server" "${prefix}add" "${prefix}use" \ "${prefix}generate" "${prefix}insert" "${prefix}server" "${prefix}add" \
"${prefix}init" "${prefix}upgrade"; done; } "${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")