From 8384af8b95930aabd4a54c0b96c6905528649fab Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Wed, 30 Dec 2020 13:15:33 +0200 Subject: [PATCH] =?UTF-8?q?First=20foray=20into=20=20=E2=86=92=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- abra | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/abra b/abra index b3e9462..217b8b1 100755 --- a/abra +++ b/abra @@ -13,20 +13,20 @@ The cooperative cloud utility belt 🎩🐇 Usage: abra [options] app new [--server=] [--domain=] [--pass] [--auto] abra [options] app (list|ls) [--status] [--server=] - abra [options] app deploy [--skip-check] - abra [options] app undeploy - abra [options] app config - abra [options] app (delete|rm) [--force] - abra [options] app logs [] - abra [options] app cp - abra [options] app check - abra [options] app ps - abra [options] app run [--no-tty] [--user=] ... - abra [options] app secret auto [--pass] - abra [options] app secret generate [] [--pass] - abra [options] app secret insert [--pass] - abra [options] app secret (delete|rm) (|--all) [--pass] [--force] - abra [options] app [...] + abra [options] app deploy [--skip-check] + abra [options] app undeploy + abra [options] app config + abra [options] app (delete|rm) [--force] + abra [options] app logs [] + abra [options] app cp + abra [options] app check + abra [options] app ps + abra [options] app run [--no-tty] [--user=] ... + abra [options] app secret auto [--pass] + abra [options] app secret generate [] [--pass] + abra [options] app secret insert [--pass] + abra [options] app secret (delete|rm) (|--all) [--pass] [--force] + abra [options] app [...] abra [options] server add [] [] abra [options] server (list|ls) abra [options] server rm @@ -142,8 +142,8 @@ 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:1466} -usage=${DOC:40:1158}; digest=f9a9a +printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1424} +usage=${DOC:40:1116}; digest=479f2 shorts=(-e -h -s -v '' '' '' '' '' '' '' '' '' '') longs=(--env --help --stack --version --server --domain --pass --auto --status --skip-check --force --no-tty --user --all) argcounts=(1 0 1 0 1 1 0 0 0 0 0 0 1 0); node_0(){ value __env 0; }; node_1(){ @@ -152,7 +152,7 @@ switch __help 1; }; node_2(){ value __stack 2; }; node_3(){ switch __version 3 switch __pass 6; }; node_7(){ switch __auto 7; }; node_8(){ switch __status 8; } node_9(){ switch __skip_check 9; }; node_10(){ switch __force 10; }; node_11(){ switch __no_tty 11; }; node_12(){ value __user 12; }; node_13(){ switch __all 13 -}; node_14(){ value _type_ a; }; node_15(){ value _domain_ a; }; node_16(){ +}; node_14(){ value _type_ a; }; node_15(){ value _app_ a; }; node_16(){ value _service_ a; }; node_17(){ value _src_ a; }; node_18(){ value _dst_ a; } node_19(){ value _args_ a true; }; node_20(){ value _secret_ a; }; node_21(){ value _version_ a; }; node_22(){ value _cmd_ a; }; node_23(){ value _data_ a; } @@ -190,11 +190,11 @@ required 52 46 25 48; }; node_94(){ required 52 46 25 49 60; }; node_95(){ required 52 50; }; node_96(){ either 57 61 63 64 65 69 71 72 73 74 78 79 81 82 85 87 90 91 92 93 94 95; } node_97(){ required 96; }; cat <<<' docopt_exit() { -[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1158}" >&2 +[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1116}" >&2 exit 1; }'; unset var___env var___help var___stack var___version var___server \ var___domain var___pass var___auto var___status var___skip_check var___force \ -var___no_tty var___user var___all var__type_ var__domain_ var__service_ \ -var__src_ var__dst_ var__args_ var__secret_ var__version_ var__cmd_ var__data_ \ +var___no_tty var___user var___all var__type_ var__app_ var__service_ var__src_ \ +var__dst_ var__args_ var__secret_ var__version_ var__cmd_ var__data_ \ var__command_ var__host_ var__user_ var__port_ var_app var_new var_list var_ls \ var_deploy var_undeploy var_config var_delete var_rm var_logs var_cp var_check \ var_ps var_run var_secret var_auto var_generate var_insert var_server var_add \ @@ -203,7 +203,7 @@ unset "${prefix}__env" "${prefix}__help" "${prefix}__stack" \ "${prefix}__version" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \ "${prefix}__auto" "${prefix}__status" "${prefix}__skip_check" \ "${prefix}__force" "${prefix}__no_tty" "${prefix}__user" "${prefix}__all" \ -"${prefix}_type_" "${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" \ +"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" \ "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" "${prefix}_host_" \ "${prefix}_user_" "${prefix}_port_" "${prefix}app" "${prefix}new" \ @@ -226,8 +226,7 @@ eval "${prefix}"'__force=${var___force:-false}' eval "${prefix}"'__no_tty=${var___no_tty:-false}' eval "${prefix}"'__user=${var___user:-}' eval "${prefix}"'__all=${var___all:-false}' -eval "${prefix}"'_type_=${var__type_:-}' -eval "${prefix}"'_domain_=${var__domain_:-}' +eval "${prefix}"'_type_=${var__type_:-}'; eval "${prefix}"'_app_=${var__app_:-}' eval "${prefix}"'_service_=${var__service_:-}' eval "${prefix}"'_src_=${var__src_:-}'; eval "${prefix}"'_dst_=${var__dst_:-}' if declare -p var__args_ >/dev/null 2>&1; then @@ -263,7 +262,7 @@ declare -p "${prefix}__env" "${prefix}__help" "${prefix}__stack" \ "${prefix}__version" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \ "${prefix}__auto" "${prefix}__status" "${prefix}__skip_check" \ "${prefix}__force" "${prefix}__no_tty" "${prefix}__user" "${prefix}__all" \ -"${prefix}_type_" "${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" \ +"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}_dst_" "${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" \ "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" "${prefix}_host_" \ "${prefix}_user_" "${prefix}_port_" "${prefix}app" "${prefix}new" \ @@ -347,7 +346,7 @@ load_custom_commands() { source abra-commands.sh fi - if [ -n "$abra__domain_" ]; then + if [ -n "$abra__app_" ]; then load_instance load_instance_env require_app_latest "$APP" @@ -384,7 +383,7 @@ get_app_keys() { } load_instance() { - DOMAIN="$abra__domain_" + DOMAIN="$abra__app_" # FIXME 3wc: requires bash 4, use for loop instead mapfile -t ENV_FILES < <(find -L "$ABRA_DIR" -name "$DOMAIN.env") case "${#ENV_FILES[@]}" in @@ -595,7 +594,7 @@ sub_app_new (){ sed -i "s/$APP\.example\.com/$DOMAIN/g" "$ENV_FILE" sed -i "s/example\.com/$DOMAIN/g" "$ENV_FILE" - abra__domain_="$DOMAIN" + abra__app_="$DOMAIN" get_app_secrets @@ -1020,7 +1019,7 @@ abra() { declare abra___stack abra___env abra__command_ abra__args_ \ abra__secret_ abra__version_ abra__data_ abra___user abra__host_ \ abra__type_ abra__port_ abra__user_ abra__service_ abra__src_ abra__dst_ \ - abra__domain_ abra___server abra___domain abra___force abra___pass \ + abra__app_ abra___server abra___domain abra___force abra___pass \ abra___auto abra___status abra___no_tty abra___skip_check if ! type tput > /dev/null 2>&1; then