Use bash select
, tweak args
This commit is contained in:
parent
b15a214049
commit
2daffc8694
54
abra
54
abra
@ -32,7 +32,7 @@ Usage:
|
|||||||
abra [options] server use <host>
|
abra [options] server use <host>
|
||||||
abra [options] server init <host>
|
abra [options] server init <host>
|
||||||
abra [options] upgrade
|
abra [options] upgrade
|
||||||
abra [options] <command> <args>...
|
abra [options] <command> [<args>...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-e, --env=<path> Environment variables to load
|
-e, --env=<path> Environment variables to load
|
||||||
@ -142,11 +142,11 @@ 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:1364}
|
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1366}
|
||||||
usage=${DOC:40:1056}; digest=afcff; shorts=(-v -s -h -e '' '' '' '' '' '')
|
usage=${DOC:40:1058}; digest=a7cb3; shorts=(-h -e -s -v '' '' '' '' '' '')
|
||||||
longs=(--version --stack --help --env --server --domain --pass --force --user --all)
|
longs=(--help --env --stack --version --server --domain --pass --force --user --all)
|
||||||
argcounts=(0 1 0 1 1 1 0 0 1 0); node_0(){ switch __version 0; }; node_1(){
|
argcounts=(0 1 1 0 1 1 0 0 1 0); node_0(){ switch __help 0; }; node_1(){
|
||||||
value __stack 1; }; node_2(){ switch __help 2; }; node_3(){ value __env 3; }
|
value __env 1; }; node_2(){ value __stack 2; }; node_3(){ switch __version 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 __force 7; }; node_8(){ value __user 8; }
|
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(){
|
node_9(){ switch __all 9; }; node_10(){ value _app_ a; }; node_11(){
|
||||||
@ -180,19 +180,20 @@ optional 9 6 7; }; node_74(){ required 47 24 11 37 57 72 73; }; node_75(){
|
|||||||
optional 21; }; node_76(){ optional 22; }; node_77(){ required 47 41 42 20 75 76
|
optional 21; }; node_76(){ optional 22; }; node_77(){ required 47 41 42 20 75 76
|
||||||
}; node_78(){ required 47 41 51; }; node_79(){ required 47 41 32 20; }
|
}; node_78(){ required 47 41 51; }; node_79(){ required 47 41 32 20; }
|
||||||
node_80(){ required 47 41 43 20; }; node_81(){ required 47 41 44 20; }
|
node_80(){ required 47 41 43 20; }; node_81(){ required 47 41 44 20; }
|
||||||
node_82(){ required 47 45; }; node_83(){ required 47 23 65; }; node_84(){
|
node_82(){ required 47 45; }; node_83(){ optional 65; }; node_84(){
|
||||||
either 49 52 53 54 55 59 61 62 63 66 67 68 70 71 74 77 78 79 80 81 82 83; }
|
required 47 23 83; }; node_85(){
|
||||||
node_85(){ required 84; }; cat <<<' docopt_exit() {
|
either 49 52 53 54 55 59 61 62 63 66 67 68 70 71 74 77 78 79 80 81 82 84; }
|
||||||
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1056}" >&2
|
node_86(){ required 85; }; cat <<<' docopt_exit() {
|
||||||
exit 1; }'; unset var___version var___stack var___help var___env var___server \
|
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1058}" >&2
|
||||||
|
exit 1; }'; unset var___help var___env var___stack var___version var___server \
|
||||||
var___domain var___pass var___force var___user var___all var__app_ \
|
var___domain var___pass var___force var___user var___all var__app_ \
|
||||||
var__domain_ var__service_ var__src_ var__dst_ var__args_ var__secret_ \
|
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__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__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_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
|
var_auto var_generate var_insert var_server var_add var_use var_init var_upgrade
|
||||||
parse 85 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__version" \
|
parse 86 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__help" \
|
||||||
"${prefix}__stack" "${prefix}__help" "${prefix}__env" "${prefix}__server" \
|
"${prefix}__env" "${prefix}__stack" "${prefix}__version" "${prefix}__server" \
|
||||||
"${prefix}__domain" "${prefix}__pass" "${prefix}__force" "${prefix}__user" \
|
"${prefix}__domain" "${prefix}__pass" "${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_" \
|
||||||
@ -203,10 +204,10 @@ parse 85 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__version" \
|
|||||||
"${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}"'__version=${var___version:-false}'
|
"${prefix}upgrade"; eval "${prefix}"'__help=${var___help:-false}'
|
||||||
eval "${prefix}"'__stack=${var___stack:-}'
|
|
||||||
eval "${prefix}"'__help=${var___help:-false}'
|
|
||||||
eval "${prefix}"'__env=${var___env:-}'
|
eval "${prefix}"'__env=${var___env:-}'
|
||||||
|
eval "${prefix}"'__stack=${var___stack:-}'
|
||||||
|
eval "${prefix}"'__version=${var___version:-false}'
|
||||||
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}'
|
||||||
@ -244,8 +245,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}__version" "${prefix}__stack" "${prefix}__help" \
|
declare -p "${prefix}__help" "${prefix}__env" "${prefix}__stack" \
|
||||||
"${prefix}__env" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \
|
"${prefix}__version" "${prefix}__server" "${prefix}__domain" "${prefix}__pass" \
|
||||||
"${prefix}__force" "${prefix}__user" "${prefix}__all" "${prefix}_app_" \
|
"${prefix}__force" "${prefix}__user" "${prefix}__all" "${prefix}_app_" \
|
||||||
"${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
|
"${prefix}_domain_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
|
||||||
"${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" \
|
"${prefix}_args_" "${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" \
|
||||||
@ -422,18 +423,15 @@ sub_app_new (){
|
|||||||
if [ -z "$SERVER" ]; then
|
if [ -z "$SERVER" ]; then
|
||||||
echo "Where would you like to put $APP?"
|
echo "Where would you like to put $APP?"
|
||||||
|
|
||||||
echo -n "$(tput setaf 4)"
|
select SERVER_ITEM in "${SERVERS[@]##*/}"; do
|
||||||
for i in "${!SERVERS[@]}"; do
|
if [ 1 -le "$REPLY" ] && [ "$REPLY" -le ${#SERVERS[@]} ]; then
|
||||||
printf " %s)\t%s\n" "$i" "$(basename "${SERVERS[$i]}")"
|
SERVER="$SERVER_ITEM"
|
||||||
|
success "Selected server ${SERVER}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
echo -n "$(tput sgr0)"
|
|
||||||
|
|
||||||
read -rp "Choose server 0-$i, or Ctrl+C to quit: " SERVER_CHOICE
|
|
||||||
|
|
||||||
SERVER="${SERVERS[$SERVER_CHOICE]}"
|
|
||||||
else
|
|
||||||
SERVER="$ABRA_DIR/servers/$SERVER"
|
|
||||||
fi
|
fi
|
||||||
|
SERVER="$ABRA_DIR/servers/$SERVER"
|
||||||
|
|
||||||
if [ ! -d "$SERVER" ]; then
|
if [ ! -d "$SERVER" ]; then
|
||||||
error "Server '$SERVER' not found"
|
error "Server '$SERVER' not found"
|
||||||
|
Reference in New Issue
Block a user