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-domains-report() {
declare desc="displays a domains report for one or more apps"
local cmd="domains:report"
declare cmd="domains:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ "$APP" == "--global" ]]; then
cmd-domains-report-single "$APP" "$INFO_FLAG"

View File

@@ -6,11 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-add() {
declare desc="adds domains to app via command line"
local cmd="domains:add"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
declare cmd="domains:add"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
shift 1
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
domains_add "$@"
}

View File

@@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-add-global() {
declare desc="add global domain names via command line"
local cmd="domains:add-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
declare cmd="domains:add-global"
[[ "$1" == "$cmd" ]] && shift 1
declare DOMAIN_NAME="$1"
shift 1
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
domains_add_global "$@"
}

View File

@@ -6,10 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-clear() {
declare desc="clear all app domains"
local cmd="domains:clear"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"
declare cmd="domains:clear"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
rm -f "$APP_VHOST_PATH"

View File

@@ -6,8 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-clear-global() {
declare desc="clear global domain names via command line"
local cmd="domains:clear-global"
shift 1
declare cmd="domains:clear-global"
[[ "$1" == "$cmd" ]] && shift 1
dokku_log_info1_quiet "Clearing global domains"
domains_clear_global "$@"

View File

@@ -6,8 +6,9 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-default() {
declare desc="print app domains"
local cmd="domains"
local APP="$2"
declare cmd="domains"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
dokku_log_warn "Deprecated: Please use domains:report"
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then

View File

@@ -6,9 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-disable() {
declare desc="disable domains/VHOST support via command line"
local cmd="domains:disable"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_disable "$2"
declare cmd="domains:disable"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
domains_disable "$APP"
}
cmd-domains-disable "$@"

View File

@@ -6,9 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-enable() {
declare desc="enable domains/VHOST support via command line"
local cmd="domains:enable"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_enable "$2"
declare cmd="domains:enable"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
domains_enable "$APP"
}
cmd-domains-enable "$@"

View File

@@ -6,11 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-remove() {
declare desc="removes domains from app via command line"
local cmd="domains:remove"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
declare cmd="domains:remove"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
shift 1
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
domains_remove "$@"
}

View File

@@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-remove-global() {
declare desc="remove global domain names via command line"
local cmd="domains:remove-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
declare cmd="domains:remove-global"
[[ "$1" == "$cmd" ]] && shift 1
declare DOMAIN_NAME="$1"
shift 1
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
domains_remove_global "$@"
}

View File

@@ -6,11 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-set() {
declare desc="set domains for app via command line"
local cmd="domains:set"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
declare cmd="domains:set"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
shift 1
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
domains_set "$@"
}

View File

@@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-set-global() {
declare desc="set global domain names via command line"
local cmd="domains:set-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
declare cmd="domains:set-global"
[[ "$1" == "$cmd" ]] && shift 1
declare DOMAIN_NAME="$1"
shift 1
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
domains_set_global "$@"
}

View File

@@ -6,9 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-setup() {
declare desc="setup domains to default state via command line"
local cmd="domains:setup"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_setup "$2"
declare cmd="domains:setup"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
domains_setup "$APP"
}
cmd-domains-setup "$@"