Make config more chill, small gardening

This commit is contained in:
3wc 2020-10-29 19:39:51 +02:00
parent b5d84d5e0d
commit 5a72ed0cfb

31
abra
View File

@ -36,7 +36,7 @@ Usage:
Options: Options:
-e, --env=<path> Environment variables to load -e, --env=<path> Environment variables to load
-h, --help Show this message and exit -h, --help Show this message and exit
-s, --stack=<path> Name of the target stack -s, --stack=<stack> Name of the target stack
-v, --version Show program version -v, --version Show program version
See 'abra help <command>' to read about a specific subcommand. See 'abra help <command>' to read about a specific subcommand.
@ -142,11 +142,11 @@ 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:1274} printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1274}
usage=${DOC:40:966}; digest=f3b8b; shorts=(-e -v -s -h '' '' '' '') usage=${DOC:40:966}; digest=09ccb; shorts=(-h -e -v -s '' '' '' '')
longs=(--env --version --stack --help --server --domain --force --user) longs=(--help --env --version --stack --server --domain --force --user)
argcounts=(1 0 1 0 1 1 0 1); node_0(){ value __env 0; }; node_1(){ argcounts=(0 1 0 1 1 1 0 1); node_0(){ switch __help 0; }; node_1(){
switch __version 1; }; node_2(){ value __stack 2; }; node_3(){ switch __help 3 value __env 1; }; node_2(){ switch __version 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 __force 6; }; node_7(){ value __user 7; }; node_8(){ value _app_ a; } switch __force 6; }; node_7(){ value __user 7; }; node_8(){ value _app_ a; }
node_9(){ value _domain_ a; }; node_10(){ value _service_ a; }; node_11(){ node_9(){ value _domain_ a; }; node_10(){ value _service_ a; }; node_11(){
value _src_ a; }; node_12(){ value _dst_ a; }; node_13(){ value _args_ a true; } value _src_ a; }; node_12(){ value _dst_ a; }; node_13(){ value _args_ a true; }
@ -182,15 +182,15 @@ required 45 21 63; }; node_79(){
either 47 50 51 52 53 57 59 60 61 64 65 66 68 69 72 73 74 75 76 77 78; } either 47 50 51 52 53 57 59 60 61 64 65 66 68 69 72 73 74 75 76 77 78; }
node_80(){ required 79; }; cat <<<' docopt_exit() { node_80(){ required 79; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:966}" >&2; exit 1 [[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:966}" >&2; exit 1
}'; unset var___env var___version var___stack var___help var___server \ }'; unset var___help var___env var___version var___stack var___server \
var___domain var___force var___user var__app_ var__domain_ var__service_ \ 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__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_config var_delete var_rm var_logs var_multilogs \ 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_cp var_run var_secret var_auto var_generate var_insert var_server var_add \
var_use var_init var_upgrade; parse 80 "$@"; local prefix=${DOCOPT_PREFIX:-''} var_use var_init var_upgrade; parse 80 "$@"; local prefix=${DOCOPT_PREFIX:-''}
unset "${prefix}__env" "${prefix}__version" "${prefix}__stack" \ unset "${prefix}__help" "${prefix}__env" "${prefix}__version" \
"${prefix}__help" "${prefix}__server" "${prefix}__domain" "${prefix}__force" \ "${prefix}__stack" "${prefix}__server" "${prefix}__domain" "${prefix}__force" \
"${prefix}__user" "${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" \ "${prefix}__user" "${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}_host_" \
@ -200,10 +200,10 @@ unset "${prefix}__env" "${prefix}__version" "${prefix}__stack" \
"${prefix}logs" "${prefix}multilogs" "${prefix}cp" "${prefix}run" \ "${prefix}logs" "${prefix}multilogs" "${prefix}cp" "${prefix}run" \
"${prefix}secret" "${prefix}auto" "${prefix}generate" "${prefix}insert" \ "${prefix}secret" "${prefix}auto" "${prefix}generate" "${prefix}insert" \
"${prefix}server" "${prefix}add" "${prefix}use" "${prefix}init" \ "${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}"'__env=${var___env:-}'
eval "${prefix}"'__version=${var___version:-false}' eval "${prefix}"'__version=${var___version:-false}'
eval "${prefix}"'__stack=${var___stack:-}' eval "${prefix}"'__stack=${var___stack:-}'
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}"'__force=${var___force:-false}'
@ -238,8 +238,8 @@ 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}__env" "${prefix}__version" "${prefix}__stack" \ declare -p "${prefix}__help" "${prefix}__env" "${prefix}__version" \
"${prefix}__help" "${prefix}__server" "${prefix}__domain" "${prefix}__force" \ "${prefix}__stack" "${prefix}__server" "${prefix}__domain" "${prefix}__force" \
"${prefix}__user" "${prefix}_app_" "${prefix}_domain_" "${prefix}_service_" \ "${prefix}__user" "${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}_host_" \
@ -418,7 +418,7 @@ sub_app_new (){
echo -n "$(tput setaf 4)" echo -n "$(tput setaf 4)"
for i in "${!SERVERS[@]}"; do for i in "${!SERVERS[@]}"; do
printf " %s)\t%s\n" "$i" $(basename "${SERVERS[$i]}") printf " %s)\t%s\n" "$i" "$(basename "${SERVERS[$i]}")"
done done
echo -n "$(tput sgr0)" echo -n "$(tput sgr0)"
@ -528,7 +528,7 @@ sub_app_undeploy (){
load_instance load_instance
load_instance_env load_instance_env
warning "Un-deploy $DOMAIN from $SERVER?" warning "Un-deploy $STACK_NAME 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"
@ -537,7 +537,6 @@ sub_app_undeploy (){
###### .. app <domain> config ###### .. app <domain> config
sub_app_config (){ sub_app_config (){
load_instance load_instance
load_instance_env
$EDITOR "$ENV_FILE" $EDITOR "$ENV_FILE"
} }