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

@@ -8,8 +8,9 @@ set -eo pipefail
cmd-ps-inspect() {
declare desc="displays a sanitized version of docker inspect for an app"
local cmd="ps:inspect"
local APP="$2"
declare cmd="ps:inspect"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
@@ -18,9 +19,10 @@ cmd-ps-inspect() {
cmd-ps-report() {
declare desc="displays a ps report for one or more apps"
local cmd="ps:report"
declare cmd="ps: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

@@ -5,12 +5,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
cmd-ps-default() {
declare desc="shows running processes in all running app containers"
local cmd="ps"
declare cmd="ps"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
dokku_log_warn "Deprecated: Please use ps:report"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$2"
verify_app_name "$APP"
! (is_deployed "$APP") && dokku_log_warn "App $APP has not been deployed" && exit 0

View File

@@ -6,8 +6,10 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions"
cmd-ps-rebuild() {
declare desc="rebuilds an app from source"
local cmd="ps:rebuild"
local APP="$2"
declare cmd="ps:rebuild"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
if (is_deployed "$APP"); then

View File

@@ -6,7 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions"
cmd-ps-rebuildall() {
declare desc="rebuilds all apps from source"
local cmd="ps:rebuildall"
declare cmd="ps:rebuildall"
[[ "$1" == "$cmd" ]] && shift 1
fn-ps-parallel-cmd "rebuild"
}

View File

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

View File

@@ -7,10 +7,13 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions"
cmd-ps-restart-policy() {
declare desc="shows the restart-policy for an app"
local cmd="ps:restart-policy"
declare cmd="ps:restart-policy"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local passed_phases="deploy"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" && local APP="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
dokku_log_info2_quiet "$APP restart-policy:"
get_restart_policies "$(get_phase_file_path "$passed_phases")"

View File

@@ -6,7 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions"
cmd-ps-restartall() {
declare desc="restarts all apps via command line"
local cmd="ps:restartall"
declare cmd="ps:restartall"
[[ "$1" == "$cmd" ]] && shift 1
fn-ps-parallel-cmd "restart"
}

View File

@@ -8,8 +8,9 @@ source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions"
cmd-ps-restore() {
declare desc="starts all apps with DOKKU_APP_RESTORE not set to 0 via command line"
local cmd="ps:restore"
local APP="$2"
declare cmd="ps:restore"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local DOKKU_SCHEDULER
DOKKU_SCHEDULER=$(get_app_scheduler "$APP")

View File

@@ -6,7 +6,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
cmd-ps-retire() {
declare desc="ensures old containers are retired"
local cmd="ps:retire"
declare cmd="ps:retire"
[[ "$1" == "$cmd" ]] && shift 1
local LOCK_FILE="${DOKKU_LIB_ROOT}/data/ps/retire"
local DOKKU_SCHEDULER=$(config_get "--global" DOKKU_SCHEDULER || echo "docker-local")

View File

@@ -6,9 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions"
cmd-ps-scale() {
declare desc="sets app scaling config via command line"
local cmd="ps:scale"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
shift 1
declare cmd="ps:scale"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
ps_scale "$@"
}

View File

@@ -7,10 +7,12 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions"
cmd-ps-set-restart-policy() {
declare desc="sets app restart-policy"
local cmd="ps:set-restart-policy"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" && local APP="$2"
local RESTART_POLICY="$3"
declare cmd="ps:set-restart-policy"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" RESTART_POLICY="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local RE_RESTART_POLICY="^(no|unless-stopped|always|on-failure(:[1-9][0-9]*)?)$"
if [[ ! "$RESTART_POLICY" =~ $RE_RESTART_POLICY ]]; then

View File

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

View File

@@ -6,7 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions"
cmd-ps-startall() {
declare desc="starts all apps via command line"
local cmd="ps:startall"
declare cmd="ps:startall"
[[ "$1" == "$cmd" ]] && shift 1
fn-ps-parallel-cmd "start"
}

View File

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

View File

@@ -6,7 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions"
cmd-ps-stopall() {
declare desc="stops all apps via command line"
local cmd="ps:stopall"
declare cmd="ps:stopall"
[[ "$1" == "$cmd" ]] && shift 1
fn-ps-parallel-cmd "stop"
}