refactor: unify command declaration across codebase

This commit is contained in:
Jose Diaz-Gonzalez
2020-02-10 01:40:30 -05:00
parent b0abeb49dd
commit e67b96780d
108 changed files with 475 additions and 315 deletions

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-docker-options-report() {
declare desc="displays a docker options report for one or more apps"
local cmd="docker-options:report"
declare cmd="docker-options:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"

View File

@@ -6,11 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
cmd-docker-options-add() {
declare desc="Add a docker option to application"
local cmd="docker-options:add"
declare cmd="docker-options:add"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$2" && local APP="$2"
read -ra passed_phases <<<"$(get_phases "$3")"
shift 3 # everything else passed is the docker option
verify_app_name "$2"
read -ra passed_phases <<<"$(get_phases "$2")"
shift 2 # everything else passed is the docker option
local passed_docker_option="$*"
[[ -z "$passed_docker_option" ]] && dokku_log_fail "Please specify docker options to add to the phase"
add_passed_docker_option passed_phases[@] "${passed_docker_option[@]}"

View File

@@ -6,8 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
cmd-docker-options-clear() {
declare desc="clear a docker options from application"
declare cmd="docker-options:clear" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="docker-options:clear"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" PHASES="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"

View File

@@ -6,11 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
cmd-docker-options-default() {
declare desc="Display applications docker options"
local cmd="docker-options"
dokku_log_warn "Deprecated: Please use docker-options:report"
declare cmd="docker-options"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$2" && local APP="$2"
read -ra passed_phases <<<"$(get_phases "$3")"
dokku_log_warn "Deprecated: Please use docker-options:report"
verify_app_name "$APP"
read -ra passed_phases <<<"$(get_phases "$2")"
if [[ ! "${passed_phases[@]}" ]]; then
display_all_phases_options
else

View File

@@ -6,11 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
cmd-docker-options-remove() {
declare desc="Remove a docker option from application"
local cmd="docker-options:remove"
declare cmd="docker-options:remove"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$2" && local APP="$2"
read -ra passed_phases <<<"$(get_phases "$3")"
shift 3 # everything else passed is the docker option
verify_app_name "$APP"
read -ra passed_phases <<<"$(get_phases "$2")"
shift 2 # everything else passed is the docker option
# shellcheck disable=SC2154
[[ -z ${passed_docker_option="$@"} ]] && dokku_log_fail "Please specify docker options to remove from the phase"
remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}"