parent
6bae48431c
commit
e8c0efa91e
150
abra
150
abra
@ -11,7 +11,7 @@ DOC="
|
||||
The cooperative cloud utility belt 🎩🐇
|
||||
|
||||
Usage:
|
||||
abra [options] app new [--server=<server>] [--domain=<domain>] [--pass] <app>
|
||||
abra [options] app new [--server=<server>] [--domain=<domain>] [--pass] [--auto] <app>
|
||||
abra [options] app (list|ls)
|
||||
abra [options] app <domain> deploy
|
||||
abra [options] app <domain> undeploy
|
||||
@ -142,77 +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:1388}
|
||||
usage=${DOC:40:1080}; digest=112a7; shorts=(-e -s -v -h '' '' '' '' '' '')
|
||||
longs=(--env --stack --version --help --server --domain --pass --force --user --all)
|
||||
argcounts=(1 1 0 0 1 1 0 0 1 0); node_0(){ value __env 0; }; node_1(){
|
||||
value __stack 1; }; node_2(){ switch __version 2; }; node_3(){ switch __help 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(){ 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; }; node_49(){ optional 5; }
|
||||
node_50(){ optional 6; }; node_51(){ required 47 24 25 48 49 50 10; }
|
||||
node_52(){ either 26 27; }; node_53(){ required 52; }; node_54(){
|
||||
required 47 24 53; }; node_55(){ required 47 24 11 28; }; node_56(){
|
||||
required 47 24 11 29; }; node_57(){ required 47 24 11 30; }; node_58(){
|
||||
either 31 32; }; node_59(){ required 58; }; node_60(){ optional 7; }; node_61(){
|
||||
required 47 24 11 59 60; }; node_62(){ optional 12; }; node_63(){
|
||||
required 47 24 11 33 62; }; node_64(){ required 47 24 11 34; }; node_65(){
|
||||
required 47 24 11 35 13 14; }; node_66(){ optional 8; }; node_67(){ oneormore 15
|
||||
}; node_68(){ required 47 24 11 36 66 12 67; }; node_69(){
|
||||
required 47 24 11 36 12 67; }; node_70(){ required 47 24 11 37 38; }; node_71(){
|
||||
optional 18; }; node_72(){ required 47 24 11 37 39 16 17 71 50; }; node_73(){
|
||||
required 47 24 11 37 40 16 17 19 50; }; node_74(){ either 16 9; }; node_75(){
|
||||
required 74; }; node_76(){ optional 6 7; }; node_77(){
|
||||
required 47 24 11 37 59 75 76; }; node_78(){ optional 21; }; node_79(){
|
||||
optional 22; }; node_80(){ required 47 41 42 20 78 79; }; node_81(){
|
||||
required 47 41 53; }; node_82(){ required 47 41 32 20; }; node_83(){
|
||||
required 47 41 43 20; }; node_84(){ required 47 41 44 20; }; node_85(){
|
||||
required 47 45; }; node_86(){ optional 67; }; node_87(){ required 47 23 86; }
|
||||
node_88(){
|
||||
either 51 54 55 56 57 61 63 64 65 68 69 70 72 73 77 80 81 82 83 84 85 87; }
|
||||
node_89(){ required 88; }; cat <<<' docopt_exit() {
|
||||
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1080}" >&2
|
||||
exit 1; }'; unset var___env var___stack var___version var___help var___server \
|
||||
var___domain var___pass var___force var___user var___all var__app_ \
|
||||
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1397}
|
||||
usage=${DOC:40:1089}; digest=0f850; shorts=(-h -s -e -v '' '' '' '' '' '' '')
|
||||
longs=(--help --stack --env --version --server --domain --pass --auto --force --user --all)
|
||||
argcounts=(0 1 1 0 1 1 0 0 0 1 0); node_0(){ switch __help 0; }; node_1(){
|
||||
value __stack 1; }; node_2(){ value __env 2; }; node_3(){ switch __version 3; }
|
||||
node_4(){ value __server 4; }; node_5(){ value __domain 5; }; node_6(){
|
||||
switch __pass 6; }; node_7(){ switch __auto 7; }; node_8(){ switch __force 8; }
|
||||
node_9(){ value __user 9; }; node_10(){ switch __all 10; }; node_11(){
|
||||
value _app_ a; }; node_12(){ value _domain_ a; }; node_13(){ value _service_ a
|
||||
}; node_14(){ value _src_ a; }; node_15(){ value _dst_ a; }; node_16(){
|
||||
value _args_ a true; }; node_17(){ value _secret_ a; }; node_18(){
|
||||
value _version_ a; }; node_19(){ value _cmd_ a; }; node_20(){ value _data_ a; }
|
||||
node_21(){ value _host_ a; }; node_22(){ value _user_ a; }; node_23(){
|
||||
value _port_ a; }; node_24(){ value _command_ a; }; node_25(){ _command app; }
|
||||
node_26(){ _command new; }; node_27(){ _command list; }; node_28(){ _command ls
|
||||
}; node_29(){ _command deploy; }; node_30(){ _command undeploy; }; node_31(){
|
||||
_command config; }; node_32(){ _command delete; }; node_33(){ _command rm; }
|
||||
node_34(){ _command logs; }; node_35(){ _command multilogs; }; node_36(){
|
||||
_command cp; }; node_37(){ _command run; }; node_38(){ _command secret; }
|
||||
node_39(){ _command auto; }; node_40(){ _command generate; }; node_41(){
|
||||
_command insert; }; node_42(){ _command server; }; node_43(){ _command add; }
|
||||
node_44(){ _command use; }; node_45(){ _command init; }; node_46(){
|
||||
_command upgrade; }; node_47(){ optional 0 1 2 3; }; node_48(){ optional 47; }
|
||||
node_49(){ optional 4; }; node_50(){ optional 5; }; node_51(){ optional 6; }
|
||||
node_52(){ optional 7; }; node_53(){ required 48 25 26 49 50 51 52 11; }
|
||||
node_54(){ either 27 28; }; node_55(){ required 54; }; node_56(){
|
||||
required 48 25 55; }; node_57(){ required 48 25 12 29; }; node_58(){
|
||||
required 48 25 12 30; }; node_59(){ required 48 25 12 31; }; node_60(){
|
||||
either 32 33; }; node_61(){ required 60; }; node_62(){ optional 8; }; node_63(){
|
||||
required 48 25 12 61 62; }; node_64(){ optional 13; }; node_65(){
|
||||
required 48 25 12 34 64; }; node_66(){ required 48 25 12 35; }; node_67(){
|
||||
required 48 25 12 36 14 15; }; node_68(){ optional 9; }; node_69(){ oneormore 16
|
||||
}; node_70(){ required 48 25 12 37 68 13 69; }; node_71(){
|
||||
required 48 25 12 37 13 69; }; node_72(){ required 48 25 12 38 39; }; node_73(){
|
||||
optional 19; }; node_74(){ required 48 25 12 38 40 17 18 73 51; }; node_75(){
|
||||
required 48 25 12 38 41 17 18 20 51; }; node_76(){ either 17 10; }; node_77(){
|
||||
required 76; }; node_78(){ optional 6 8; }; node_79(){
|
||||
required 48 25 12 38 61 77 78; }; node_80(){ optional 22; }; node_81(){
|
||||
optional 23; }; node_82(){ required 48 42 43 21 80 81; }; node_83(){
|
||||
required 48 42 55; }; node_84(){ required 48 42 33 21; }; node_85(){
|
||||
required 48 42 44 21; }; node_86(){ required 48 42 45 21; }; node_87(){
|
||||
required 48 46; }; node_88(){ optional 69; }; node_89(){ required 48 24 88; }
|
||||
node_90(){
|
||||
either 53 56 57 58 59 63 65 66 67 70 71 72 74 75 79 82 83 84 85 86 87 89; }
|
||||
node_91(){ required 90; }; cat <<<' docopt_exit() {
|
||||
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1089}" >&2
|
||||
exit 1; }'; unset var___help var___stack var___env var___version var___server \
|
||||
var___domain var___pass var___auto 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 89 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__env" \
|
||||
"${prefix}__stack" "${prefix}__version" "${prefix}__help" "${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" \
|
||||
parse 91 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__help" \
|
||||
"${prefix}__stack" "${prefix}__env" "${prefix}__version" "${prefix}__server" \
|
||||
"${prefix}__domain" "${prefix}__pass" "${prefix}__auto" "${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"; eval "${prefix}"'__env=${var___env:-}'
|
||||
"${prefix}upgrade"; eval "${prefix}"'__help=${var___help:-false}'
|
||||
eval "${prefix}"'__stack=${var___stack:-}'
|
||||
eval "${prefix}"'__env=${var___env:-}'
|
||||
eval "${prefix}"'__version=${var___version:-false}'
|
||||
eval "${prefix}"'__help=${var___help:-false}'
|
||||
eval "${prefix}"'__server=${var___server:-}'
|
||||
eval "${prefix}"'__domain=${var___domain:-}'
|
||||
eval "${prefix}"'__pass=${var___pass:-false}'
|
||||
eval "${prefix}"'__auto=${var___auto:-false}'
|
||||
eval "${prefix}"'__force=${var___force:-false}'
|
||||
eval "${prefix}"'__user=${var___user:-}'
|
||||
eval "${prefix}"'__all=${var___all:-false}'
|
||||
@ -247,18 +249,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}__env" "${prefix}__stack" "${prefix}__version" \
|
||||
"${prefix}__help" "${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; }
|
||||
declare -p "${prefix}__help" "${prefix}__stack" "${prefix}__env" \
|
||||
"${prefix}__version" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \
|
||||
"${prefix}__auto" "${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")
|
||||
@ -482,12 +484,8 @@ sub_app_new (){
|
||||
abra__domain_="$DOMAIN"
|
||||
|
||||
get_app_secrets
|
||||
|
||||
if [ "${#SECRETS[@]}" -gt 0 ]; then
|
||||
read -rp "Generate ${#SECRETS[@]} secrets? ([y]/n) " SECRETS_CONFIRM
|
||||
if [ "$SECRETS_CONFIRM" != "n" ]; then
|
||||
sub_app_secret_auto
|
||||
fi
|
||||
if [ "${#SECRETS[@]}" -gt 0 ] && [ "$abra___auto" == "true" ]; then
|
||||
sub_app_secret_auto
|
||||
fi
|
||||
|
||||
echo "$(tput setaf 4)Your new '$APP' is ready for action:$(tput sgr0)"
|
||||
|
Reference in New Issue
Block a user