subcommand restructure and bashstyle refactor. closes #1579

This commit is contained in:
Michael S. Hobbs
2016-03-01 13:26:35 -08:00
committed by Michael Hobbs
parent 76e27f0333
commit 89f289b433
105 changed files with 1969 additions and 1306 deletions

View File

@@ -1,26 +1,8 @@
#!/usr/bin/env bash
[[ " config config:get config:set config:unset help config:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
[[ " help config:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
case "$1" in
config)
config_all "$@"
;;
config:get)
config_get "$@"
;;
config:set)
config_set "$@"
;;
config:unset)
config_unset "$@"
;;
help | config:help)
cat<<EOF
config (<app>|--global), Display all global or app-specific config vars

View File

@@ -3,6 +3,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
config_export() {
local desc="returns export command for config variable of specified type (app/global)"
local CONFIG_TYPE="$1"
local APP="$2"
local ENV_FILE="$DOKKU_ROOT/$APP/ENV"
@@ -17,6 +18,7 @@ config_export() {
}
config_parse_args() {
local desc="parse config plugin args"
unset APP ENV_FILE DOKKU_CONFIG_TYPE DOKKU_CONFIG_RESTART
case "$2" in
--global)
@@ -48,11 +50,13 @@ config_parse_args() {
}
config_create () {
local desc="create config env file"
local ENV_FILE=$1
[[ -f $ENV_FILE ]] || touch "$ENV_FILE"
}
config_styled_hash () {
local desc="internal config hash"
local vars="$1"
local prefix="$2"
local longest=""
@@ -79,6 +83,7 @@ config_styled_hash () {
}
config_write() {
local desc="writes config vars out to appropriate file path"
local ENV_TEMP="$1"
local ENV_FILE_TEMP="${ENV_FILE}.tmp"
@@ -91,6 +96,7 @@ config_write() {
}
is_config_export() {
local desc="return 0 if we're supposed to export"
for var in "$@"; do
if [[ "$var" == "--export" ]]; then
return 0
@@ -100,6 +106,7 @@ is_config_export() {
}
config_all() {
local desc="print or export config vars"
[[ "$1" == "config" ]] || set -- "config" "$@"
config_parse_args "$@"
@@ -123,6 +130,7 @@ config_all() {
}
config_get() {
local desc="get value of given config var"
[[ "$1" == "config:get" ]] || set -- "config:get" "$@"
config_parse_args "$@"
@@ -143,6 +151,7 @@ config_get() {
}
config_set() {
local desc="set value of given config var"
[[ "$1" == "config:set" ]] || set -- "config:set" "$@"
config_parse_args "$@"
[[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}"
@@ -200,6 +209,7 @@ ${var}"
}
config_unset() {
local desc="unset given config var"
[[ "$1" == "config:unset" ]] || set -- "config:unset" "$@"
config_parse_args "$@"
[[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}"

View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
config_main_cmd() {
local desc="print config vars for app via command line"
local cmd="config"
config_all "$@"
}
config_main_cmd "$@"

11
plugins/config/subcommands/get Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
config_get_cmd() {
local desc="get specified config vars from app via command line"
local cmd="config:get"
config_get "$@"
}
config_get_cmd "$@"

11
plugins/config/subcommands/set Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
config_set_cmd() {
local desc="set specified config vars for app via command line"
local cmd="config:set"
config_set "$@"
}
config_set_cmd "$@"

View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
config_unset_cmd() {
local desc="unset specified config vars for app via command line"
local cmd="config:unset"
config_unset "$@"
}
config_unset_cmd "$@"