Tweak info/debug output
This commit is contained in:
parent
854ae23f60
commit
6cc265e931
115
abra
115
abra
@ -150,15 +150,15 @@ 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:1696}
|
||||
usage=${DOC:40:1320}; digest=563d5
|
||||
shorts=(-h -s -e -U -C '' '' '' '' '' '' '' '' '' '')
|
||||
longs=(--help --stack --env --skip-update --skip-check --status --server --domain --app-name --pass --secrets --all --force --no-tty --user)
|
||||
argcounts=(0 1 1 0 0 0 1 1 1 0 0 0 0 0 1); node_0(){ switch __help 0; }
|
||||
node_1(){ value __stack 1; }; node_2(){ value __env 2; }; node_3(){
|
||||
switch __skip_update 3; }; node_4(){ switch __skip_check 4; }; node_5(){
|
||||
value __stack 5; }; node_6(){ switch __verbose 6; }; node_7(){ switch __status 7
|
||||
}; node_8(){ value __server 8; }; node_9(){ value __domain 9; }; node_10(){
|
||||
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1783}
|
||||
usage=${DOC:40:1320}; digest=616a5
|
||||
shorts=(-C -v -d -s -e -h -U '' '' '' '' '' '' '' '' '' '')
|
||||
longs=(--skip-check --verbose --debug --stack --env --help --skip-update --status --server --domain --app-name --pass --secrets --all --force --no-tty --user)
|
||||
argcounts=(0 0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 1); node_0(){ switch __skip_check 0
|
||||
}; node_1(){ switch __verbose 1; }; node_2(){ switch __debug 2; }; node_3(){
|
||||
value __stack 3; }; node_4(){ value __env 4; }; node_5(){ switch __help 5; }
|
||||
node_6(){ switch __skip_update 6; }; node_7(){ switch __status 7; }; node_8(){
|
||||
value __server 8; }; node_9(){ value __domain 9; }; node_10(){
|
||||
value __app_name 10; }; node_11(){ switch __pass 11; }; node_12(){
|
||||
switch __secrets 12; }; node_13(){ switch __all 13; }; node_14(){
|
||||
switch __force 14; }; node_15(){ switch __no_tty 15; }; node_16(){
|
||||
@ -208,39 +208,38 @@ optional 113; }; node_115(){ required 60 58 114; }; node_116(){
|
||||
either 65 70 73 74 75 76 77 79 80 81 85 87 91 96 97 100 101 103 106 107 108 109 110 111 112 115
|
||||
}; node_117(){ required 116; }; cat <<<' docopt_exit() {
|
||||
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1320}" >&2
|
||||
exit 1; }'; unset var___debug var___help var___env var___skip_update \
|
||||
var___skip_check var___stack var___verbose var___status var___server \
|
||||
var___domain var___app_name var___pass var___secrets var___all var___force \
|
||||
var___no_tty var___user var__type_ var__app_ var__service_ var__src_ var__dst_ \
|
||||
exit 1; }'; unset var___skip_check var___verbose var___debug var___stack \
|
||||
var___env var___help var___skip_update var___status var___server var___domain \
|
||||
var___app_name var___pass var___secrets var___all var___force 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__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_secret var_generate \
|
||||
var_insert var_undeploy var_server var_add var_init var_apps var_upgrade \
|
||||
var_version var_help; parse 117 "$@"; local prefix=${DOCOPT_PREFIX:-''}
|
||||
unset "${prefix}__debug" "${prefix}__help" "${prefix}__env" \
|
||||
"${prefix}__skip_update" "${prefix}__skip_check" "${prefix}__stack" \
|
||||
"${prefix}__verbose" "${prefix}__status" "${prefix}__server" \
|
||||
"${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \
|
||||
"${prefix}__secrets" "${prefix}__all" "${prefix}__force" "${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}_subcommands_" "${prefix}app" "${prefix}list" "${prefix}ls" \
|
||||
"${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \
|
||||
"${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \
|
||||
"${prefix}restore" "${prefix}rm" "${prefix}delete" "${prefix}run" \
|
||||
"${prefix}secret" "${prefix}generate" "${prefix}insert" "${prefix}undeploy" \
|
||||
"${prefix}server" "${prefix}add" "${prefix}init" "${prefix}apps" \
|
||||
"${prefix}upgrade" "${prefix}version" "${prefix}help"
|
||||
eval "${prefix}"'__debug=${var___debug:-false}'
|
||||
eval "${prefix}"'__help=${var___help:-false}'
|
||||
eval "${prefix}"'__env=${var___env:-}'
|
||||
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
|
||||
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
|
||||
eval "${prefix}"'__stack=${var___stack:-}'
|
||||
unset "${prefix}__skip_check" "${prefix}__verbose" "${prefix}__debug" \
|
||||
"${prefix}__stack" "${prefix}__env" "${prefix}__help" "${prefix}__skip_update" \
|
||||
"${prefix}__status" "${prefix}__server" "${prefix}__domain" \
|
||||
"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \
|
||||
"${prefix}__force" "${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}_subcommands_" \
|
||||
"${prefix}app" "${prefix}list" "${prefix}ls" "${prefix}new" "${prefix}backup" \
|
||||
"${prefix}deploy" "${prefix}check" "${prefix}config" "${prefix}cp" \
|
||||
"${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \
|
||||
"${prefix}delete" "${prefix}run" "${prefix}secret" "${prefix}generate" \
|
||||
"${prefix}insert" "${prefix}undeploy" "${prefix}server" "${prefix}add" \
|
||||
"${prefix}init" "${prefix}apps" "${prefix}upgrade" "${prefix}version" \
|
||||
"${prefix}help"; eval "${prefix}"'__skip_check=${var___skip_check:-false}'
|
||||
eval "${prefix}"'__verbose=${var___verbose:-false}'
|
||||
eval "${prefix}"'__debug=${var___debug:-false}'
|
||||
eval "${prefix}"'__stack=${var___stack:-}'
|
||||
eval "${prefix}"'__env=${var___env:-}'
|
||||
eval "${prefix}"'__help=${var___help:-false}'
|
||||
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
|
||||
eval "${prefix}"'__status=${var___status:-false}'
|
||||
eval "${prefix}"'__server=${var___server:-}'
|
||||
eval "${prefix}"'__domain=${var___domain:-}'
|
||||
@ -291,22 +290,22 @@ 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}__debug" "${prefix}__help" "${prefix}__env" \
|
||||
"${prefix}__skip_update" "${prefix}__skip_check" "${prefix}__stack" \
|
||||
"${prefix}__verbose" "${prefix}__status" "${prefix}__server" \
|
||||
"${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \
|
||||
"${prefix}__secrets" "${prefix}__all" "${prefix}__force" "${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}_subcommands_" "${prefix}app" "${prefix}list" "${prefix}ls" \
|
||||
"${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \
|
||||
"${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \
|
||||
"${prefix}restore" "${prefix}rm" "${prefix}delete" "${prefix}run" \
|
||||
"${prefix}secret" "${prefix}generate" "${prefix}insert" "${prefix}undeploy" \
|
||||
"${prefix}server" "${prefix}add" "${prefix}init" "${prefix}apps" \
|
||||
"${prefix}upgrade" "${prefix}version" "${prefix}help"; done; }
|
||||
declare -p "${prefix}__skip_check" "${prefix}__verbose" "${prefix}__debug" \
|
||||
"${prefix}__stack" "${prefix}__env" "${prefix}__help" "${prefix}__skip_update" \
|
||||
"${prefix}__status" "${prefix}__server" "${prefix}__domain" \
|
||||
"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \
|
||||
"${prefix}__force" "${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}_subcommands_" \
|
||||
"${prefix}app" "${prefix}list" "${prefix}ls" "${prefix}new" "${prefix}backup" \
|
||||
"${prefix}deploy" "${prefix}check" "${prefix}config" "${prefix}cp" \
|
||||
"${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \
|
||||
"${prefix}delete" "${prefix}run" "${prefix}secret" "${prefix}generate" \
|
||||
"${prefix}insert" "${prefix}undeploy" "${prefix}server" "${prefix}add" \
|
||||
"${prefix}init" "${prefix}apps" "${prefix}upgrade" "${prefix}version" \
|
||||
"${prefix}help"; done; }
|
||||
# docopt parser above, complete command for generating this parser is `docopt.sh abra`
|
||||
|
||||
PROGRAM_NAME=$(basename "$0")
|
||||
@ -341,7 +340,7 @@ debug() {
|
||||
if [ "$abra___debug" = "false" ]; then
|
||||
return
|
||||
fi
|
||||
echo "$(tput setaf 10)DEBUG: $*$(tput sgr0)"
|
||||
echo "$(tput setaf 13)DEBUG: $*$(tput sgr0)"
|
||||
}
|
||||
|
||||
###### Default settings
|
||||
@ -378,7 +377,7 @@ require_app_latest() {
|
||||
APP="$1"
|
||||
APP_DIR="$ABRA_DIR/apps/$APP"
|
||||
|
||||
info "Checking for $APP"
|
||||
debug "Checking for type '$APP'"
|
||||
|
||||
if [ ! -d "$APP_DIR" ]; then
|
||||
warning "The app type '$APP' was not found, fetching via Git"
|
||||
@ -386,10 +385,10 @@ require_app_latest() {
|
||||
error "Could not retrieve app type '$APP', this app type doesn't exist?"
|
||||
fi
|
||||
success "Fetched app configuration via Git"
|
||||
else
|
||||
info "Found $APP_DIR"
|
||||
fi
|
||||
|
||||
debug "Using $APP_DIR"
|
||||
|
||||
if [ "$abra___skip_update" = "false" ]; then
|
||||
(cd "$APP_DIR" && git pull > /dev/null 2>&1)
|
||||
else
|
||||
@ -452,7 +451,7 @@ load_instance() {
|
||||
esac
|
||||
|
||||
ENV_FILE="${ENV_FILES[0]}"
|
||||
info "Loaded ENV_FILE $ENV_FILE"
|
||||
debug "Selected ENV_FILE $ENV_FILE"
|
||||
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
error "Can't open ENV_FILE '$ENV_FILE'"
|
||||
@ -472,7 +471,7 @@ load_instance_env() {
|
||||
source "$ENV_FILE"
|
||||
set +a
|
||||
|
||||
info "Loaded variables from $ENV_FILE"
|
||||
debug "Loaded variables from $ENV_FILE"
|
||||
|
||||
if [ -z "$TYPE" ]; then
|
||||
error "TYPE not set, maybe $ENV_FILE is using an old format?"
|
||||
@ -480,7 +479,7 @@ load_instance_env() {
|
||||
|
||||
APP_DIR="$ABRA_DIR/apps/$TYPE"
|
||||
export DOCKER_CONTEXT="$SERVER"
|
||||
info "Setting DOCKER_CONTEXT $DOCKER_CONTEXT"
|
||||
info "Setting DOCKER_CONTEXT=$DOCKER_CONTEXT"
|
||||
|
||||
export DOMAIN
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user