Add --type filter to abra <app> ls

This commit is contained in:
3wc 2021-03-12 13:08:21 +02:00
parent 5bce042922
commit 08281891a1

199
abra
View File

@ -13,7 +13,7 @@ DOC="
The cooperative cloud utility belt 🎩🐇
Usage:
abra [options] app (list|ls) [--status] [--server=<server>]
abra [options] app (list|ls) [--status] [--server=<server>] [--type=<type>]
abra [options] app new [--server=<server>] [--domain=<domain>] [--app-name=<app_name>] [--pass] [--secrets] <type>
abra [options] app <app> backup (<service>|--all)
abra [options] app <app> deploy [--update]
@ -155,87 +155,89 @@ 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:1993}
usage=${DOC:40:1457}; digest=06b80
shorts=(-C -v -b -e -U -d -s -h '' '' '' '' '' '' '' '' '' '' '' '')
longs=(--skip-check --verbose --branch --env --skip-update --debug --stack --help --status --server --domain --app-name --pass --secrets --all --update --force --volumes --no-tty --user)
argcounts=(0 0 1 1 0 0 1 0 0 1 1 1 0 0 0 0 0 0 0 1); node_0(){
switch __skip_check 0; }; node_1(){ switch __verbose 1; }; node_2(){
value __branch 2; }; node_3(){ value __env 3; }; node_4(){
switch __skip_update 4; }; node_5(){ switch __debug 5; }; node_6(){
value __stack 6; }; node_7(){ switch __help 7; }; node_8(){ switch __status 8; }
node_9(){ value __server 9; }; node_10(){ value __domain 10; }; node_11(){
value __app_name 11; }; node_12(){ switch __pass 12; }; node_13(){
switch __secrets 13; }; node_14(){ switch __all 14; }; node_15(){
switch __update 15; }; node_16(){ switch __force 16; }; node_17(){
switch __volumes 17; }; node_18(){ switch __no_tty 18; }; node_19(){
value __user 19; }; node_20(){ value _type_ a; }; node_21(){ value _app_ a; }
node_22(){ value _service_ a; }; node_23(){ value _src_ a; }; node_24(){
value _dst_ a; }; node_25(){ value _backup_file_ a; }; node_26(){
value _args_ a true; }; node_27(){ value _secret_ a; }; node_28(){
value _version_ a; }; node_29(){ value _cmd_ a; }; node_30(){ value _data_ a; }
node_31(){ value _command_ a; }; node_32(){ value _host_ a; }; node_33(){
value _user_ a; }; node_34(){ value _port_ a; }; node_35(){ value _provider_ a
}; node_36(){ value _subcommands_ a true; }; node_37(){ _command app; }
node_38(){ _command list; }; node_39(){ _command ls; }; node_40(){ _command new
}; node_41(){ _command backup; }; node_42(){ _command deploy; }; node_43(){
_command check; }; node_44(){ _command config; }; node_45(){ _command cp; }
node_46(){ _command logs; }; node_47(){ _command ps; }; node_48(){
_command restore; }; node_49(){ _command rm; }; node_50(){ _command delete; }
node_51(){ _command run; }; node_52(){ _command rollback; }; node_53(){
_command secret; }; node_54(){ _command generate; }; node_55(){ _command insert
}; node_56(){ _command undeploy; }; node_57(){ _command server; }; node_58(){
_command add; }; node_59(){ _command init; }; node_60(){ _command apps; }
node_61(){ _command upgrade; }; node_62(){ _command version; }; node_63(){
_command help; }; node_64(){ optional 0 1 2 3 4 5 6 7; }; node_65(){ optional 64
}; node_66(){ either 38 39; }; node_67(){ required 66; }; node_68(){ optional 8
}; node_69(){ optional 9; }; node_70(){ required 65 37 67 68 69; }; node_71(){
optional 10; }; node_72(){ optional 11; }; node_73(){ optional 12; }; node_74(){
optional 13; }; node_75(){ required 65 37 40 69 71 72 73 74 20; }; node_76(){
either 22 14; }; node_77(){ required 76; }; node_78(){ required 65 37 21 41 77
}; node_79(){ optional 15; }; node_80(){ required 65 37 21 42 79; }; node_81(){
required 65 37 21 43; }; node_82(){ required 65 37 21 44; }; node_83(){
required 65 37 21 45 23 24; }; node_84(){ optional 22; }; node_85(){
required 65 37 21 46 84; }; node_86(){ required 65 37 21 47; }; node_87(){
required 65 37 21 48 77; }; node_88(){ either 49 50; }; node_89(){ required 88
}; node_90(){ optional 16; }; node_91(){ optional 17; }; node_92(){
required 65 37 21 89 90 91 74; }; node_93(){ optional 25; }; node_94(){
required 65 37 21 48 22 93; }; node_95(){ optional 18; }; node_96(){ optional 19
}; node_97(){ oneormore 26; }; node_98(){ required 65 37 21 51 95 96 22 97; }
node_99(){ required 65 37 21 52 22; }; node_100(){ required 27 28; }
node_101(){ either 100 14; }; node_102(){ required 101; }; node_103(){
optional 29; }; node_104(){ required 65 37 21 53 54 102 103 73; }; node_105(){
required 65 37 21 53 55 27 28 30 73; }; node_106(){ either 27 14; }; node_107(){
required 106; }; node_108(){ required 65 37 21 53 89 107 73 90; }; node_109(){
required 65 37 21 56; }; node_110(){ optional 97; }; node_111(){
required 65 37 21 31 110; }; node_112(){ optional 33; }; node_113(){ optional 34
}; node_114(){ required 65 57 58 32 112 113; }; node_115(){ required 65 57 40 35
}; node_116(){ required 65 57 67; }; node_117(){ required 65 57 32 49; }
node_118(){ required 65 57 32 59; }; node_119(){ required 65 57 32 60 68; }
node_120(){ required 65 61; }; node_121(){ required 65 62; }; node_122(){
oneormore 36; }; node_123(){ optional 122; }; node_124(){ required 65 63 123; }
node_125(){ required 65; }; node_126(){
either 70 75 78 80 81 82 83 85 86 87 92 94 98 99 104 105 108 109 111 114 115 116 117 118 119 120 121 124 125
}; node_127(){ required 126; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1457}" >&2
exit 1; }'; unset var___skip_check var___verbose var___branch var___env \
var___skip_update var___debug var___stack var___help var___status var___server \
var___domain var___app_name var___pass var___secrets var___all var___update \
var___force var___volumes var___no_tty var___user var__type_ var__app_ \
var__service_ var__src_ var__dst_ var__backup_file_ var__args_ var__secret_ \
var__version_ var__cmd_ var__data_ var__command_ var__host_ var__user_ \
var__port_ var__provider_ var__subcommands_ var_app var_list var_ls var_new \
var_backup var_deploy var_check var_config var_cp var_logs var_ps var_restore \
var_rm var_delete var_run var_rollback var_secret var_generate var_insert \
var_undeploy var_server var_add var_init var_apps var_upgrade var_version \
var_help; parse 127 "$@"; local prefix=${DOCOPT_PREFIX:-''}
unset "${prefix}__skip_check" "${prefix}__verbose" "${prefix}__branch" \
"${prefix}__env" "${prefix}__skip_update" "${prefix}__debug" \
"${prefix}__stack" "${prefix}__help" "${prefix}__status" "${prefix}__server" \
"${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \
"${prefix}__secrets" "${prefix}__all" "${prefix}__update" "${prefix}__force" \
"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" \
"${prefix}_app_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:2009}
usage=${DOC:40:1473}; digest=2c4e4
shorts=(-b -s -e -d -C -v -U -h '' '' '' '' '' '' '' '' '' '' '' '' '')
longs=(--branch --stack --env --debug --skip-check --verbose --skip-update --help --status --server --type --domain --app-name --pass --secrets --all --update --force --volumes --no-tty --user)
argcounts=(1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 1); node_0(){
value __branch 0; }; node_1(){ value __stack 1; }; node_2(){ value __env 2; }
node_3(){ switch __debug 3; }; node_4(){ switch __skip_check 4; }; node_5(){
switch __verbose 5; }; node_6(){ switch __skip_update 6; }; node_7(){
switch __help 7; }; node_8(){ switch __status 8; }; node_9(){ value __server 9
}; node_10(){ value __type 10; }; node_11(){ value __domain 11; }; node_12(){
value __app_name 12; }; node_13(){ switch __pass 13; }; node_14(){
switch __secrets 14; }; node_15(){ switch __all 15; }; node_16(){
switch __update 16; }; node_17(){ switch __force 17; }; node_18(){
switch __volumes 18; }; node_19(){ switch __no_tty 19; }; node_20(){
value __user 20; }; node_21(){ value _type_ a; }; node_22(){ value _app_ a; }
node_23(){ value _service_ a; }; node_24(){ value _src_ a; }; node_25(){
value _dst_ a; }; node_26(){ value _backup_file_ a; }; node_27(){
value _args_ a true; }; node_28(){ value _secret_ a; }; node_29(){
value _version_ a; }; node_30(){ value _cmd_ a; }; node_31(){ value _data_ a; }
node_32(){ value _command_ a; }; node_33(){ value _host_ a; }; node_34(){
value _user_ a; }; node_35(){ value _port_ a; }; node_36(){ value _provider_ a
}; node_37(){ value _subcommands_ a true; }; node_38(){ _command app; }
node_39(){ _command list; }; node_40(){ _command ls; }; node_41(){ _command new
}; node_42(){ _command backup; }; node_43(){ _command deploy; }; node_44(){
_command check; }; node_45(){ _command config; }; node_46(){ _command cp; }
node_47(){ _command logs; }; node_48(){ _command ps; }; node_49(){
_command restore; }; node_50(){ _command rm; }; node_51(){ _command delete; }
node_52(){ _command run; }; node_53(){ _command rollback; }; node_54(){
_command secret; }; node_55(){ _command generate; }; node_56(){ _command insert
}; node_57(){ _command undeploy; }; node_58(){ _command server; }; node_59(){
_command add; }; node_60(){ _command init; }; node_61(){ _command apps; }
node_62(){ _command upgrade; }; node_63(){ _command version; }; node_64(){
_command help; }; node_65(){ optional 0 1 2 3 4 5 6 7; }; node_66(){ optional 65
}; node_67(){ either 39 40; }; node_68(){ required 67; }; node_69(){ optional 8
}; node_70(){ optional 9; }; node_71(){ optional 10; }; node_72(){
required 66 38 68 69 70 71; }; node_73(){ optional 11; }; node_74(){ optional 12
}; node_75(){ optional 13; }; node_76(){ optional 14; }; node_77(){
required 66 38 41 70 73 74 75 76 21; }; node_78(){ either 23 15; }; node_79(){
required 78; }; node_80(){ required 66 38 22 42 79; }; node_81(){ optional 16; }
node_82(){ required 66 38 22 43 81; }; node_83(){ required 66 38 22 44; }
node_84(){ required 66 38 22 45; }; node_85(){ required 66 38 22 46 24 25; }
node_86(){ optional 23; }; node_87(){ required 66 38 22 47 86; }; node_88(){
required 66 38 22 48; }; node_89(){ required 66 38 22 49 79; }; node_90(){
either 50 51; }; node_91(){ required 90; }; node_92(){ optional 17; }
node_93(){ optional 18; }; node_94(){ required 66 38 22 91 92 93 76; }
node_95(){ optional 26; }; node_96(){ required 66 38 22 49 23 95; }; node_97(){
optional 19; }; node_98(){ optional 20; }; node_99(){ oneormore 27; }
node_100(){ required 66 38 22 52 97 98 23 99; }; node_101(){
required 66 38 22 53 23; }; node_102(){ required 28 29; }; node_103(){
either 102 15; }; node_104(){ required 103; }; node_105(){ optional 30; }
node_106(){ required 66 38 22 54 55 104 105 75; }; node_107(){
required 66 38 22 54 56 28 29 31 75; }; node_108(){ either 28 15; }; node_109(){
required 108; }; node_110(){ required 66 38 22 54 91 109 75 92; }; node_111(){
required 66 38 22 57; }; node_112(){ optional 99; }; node_113(){
required 66 38 22 32 112; }; node_114(){ optional 34; }; node_115(){ optional 35
}; node_116(){ required 66 58 59 33 114 115; }; node_117(){ required 66 58 41 36
}; node_118(){ required 66 58 68; }; node_119(){ required 66 58 33 50; }
node_120(){ required 66 58 33 60; }; node_121(){ required 66 58 33 61 69; }
node_122(){ required 66 62; }; node_123(){ required 66 63; }; node_124(){
oneormore 37; }; node_125(){ optional 124; }; node_126(){ required 66 64 125; }
node_127(){ required 66; }; node_128(){
either 72 77 80 82 83 84 85 87 88 89 94 96 100 101 106 107 110 111 113 116 117 118 119 120 121 122 123 126 127
}; node_129(){ required 128; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1473}" >&2
exit 1; }'; unset var___branch var___stack var___env var___debug \
var___skip_check var___verbose var___skip_update var___help var___status \
var___server var___type var___domain var___app_name var___pass var___secrets \
var___all var___update var___force var___volumes var___no_tty var___user \
var__type_ var__app_ var__service_ var__src_ var__dst_ var__backup_file_ \
var__args_ var__secret_ var__version_ var__cmd_ var__data_ var__command_ \
var__host_ var__user_ var__port_ var__provider_ var__subcommands_ var_app \
var_list var_ls var_new var_backup var_deploy var_check var_config var_cp \
var_logs var_ps var_restore var_rm var_delete var_run var_rollback var_secret \
var_generate var_insert var_undeploy var_server var_add var_init var_apps \
var_upgrade var_version var_help; parse 129 "$@"
local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__branch" \
"${prefix}__stack" "${prefix}__env" "${prefix}__debug" "${prefix}__skip_check" \
"${prefix}__verbose" "${prefix}__skip_update" "${prefix}__help" \
"${prefix}__status" "${prefix}__server" "${prefix}__type" "${prefix}__domain" \
"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \
"${prefix}__update" "${prefix}__force" "${prefix}__volumes" \
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \
"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \
"${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_provider_" \
@ -246,16 +248,17 @@ unset "${prefix}__skip_check" "${prefix}__verbose" "${prefix}__branch" \
"${prefix}rollback" "${prefix}secret" "${prefix}generate" "${prefix}insert" \
"${prefix}undeploy" "${prefix}server" "${prefix}add" "${prefix}init" \
"${prefix}apps" "${prefix}upgrade" "${prefix}version" "${prefix}help"
eval "${prefix}"'__branch=${var___branch:-}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__verbose=${var___verbose:-false}'
eval "${prefix}"'__branch=${var___branch:-}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__status=${var___status:-false}'
eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__type=${var___type:-}'
eval "${prefix}"'__domain=${var___domain:-}'
eval "${prefix}"'__app_name=${var___app_name:-}'
eval "${prefix}"'__pass=${var___pass:-false}'
@ -308,13 +311,14 @@ eval "${prefix}"'upgrade=${var_upgrade:-false}'
eval "${prefix}"'version=${var_version:-false}'
eval "${prefix}"'help=${var_help:-false}'; local docopt_i=1
[[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do
declare -p "${prefix}__skip_check" "${prefix}__verbose" "${prefix}__branch" \
"${prefix}__env" "${prefix}__skip_update" "${prefix}__debug" \
"${prefix}__stack" "${prefix}__help" "${prefix}__status" "${prefix}__server" \
"${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \
"${prefix}__secrets" "${prefix}__all" "${prefix}__update" "${prefix}__force" \
"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" \
"${prefix}_app_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
declare -p "${prefix}__branch" "${prefix}__stack" "${prefix}__env" \
"${prefix}__debug" "${prefix}__skip_check" "${prefix}__verbose" \
"${prefix}__skip_update" "${prefix}__help" "${prefix}__status" \
"${prefix}__server" "${prefix}__type" "${prefix}__domain" \
"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \
"${prefix}__update" "${prefix}__force" "${prefix}__volumes" \
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \
"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \
"${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_provider_" \
@ -669,6 +673,7 @@ sub_app_list (){
done
fi
# FIXME 3wc: doesn't take into account --type filtering
printf "%s lovely apps:\n\n" "${#ENV_FILES[@]}"
for i in "${!ENV_FILES[@]}"; do
@ -693,6 +698,10 @@ sub_app_list (){
APP_STACK_NAME="$(source "$ENV_FILE" && echo "$STACK_NAME")"
set +a
if [ "$abra___type" != "" ] && [ "$abra___type" != "$TYPE" ]; then
continue
fi
if [ -z "$APP_STACK_NAME" ]; then
APP_STACK_NAME="${DOMAIN//./_}"
fi
@ -1730,7 +1739,11 @@ abra() {
abra___secrets abra___status abra___no_tty abra___app_name \
abra__subcommands_ abra___skip_update abra___skip_check \
abra__backup_file_ abra___verbose abra___debug abra___help \
<<<<<<< HEAD
abra___update abra___branch abra___volumes abra__provider_
=======
abra___update abra___branch abra___volumes abra___type
>>>>>>> 1fa2de4... Add --type filter to `abra <app> ls`
if ! type tput > /dev/null 2>&1; then
tput() {