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-apps-report() {
declare desc="displays the app report for one or more apps"
local cmd="apps:report"
declare cmd="apps: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"
@@ -80,7 +81,8 @@ cmd-apps-report-single() {
cmd-apps-list() {
declare desc="lists all apps"
local cmd="apps"
declare cmd="apps"
[[ "$1" == "$cmd" ]] && shift 1
local app
dokku_log_info2_quiet "My Apps"

View File

@@ -7,11 +7,10 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions"
cmd-apps-clone() {
declare desc="clones an app"
declare cmd="apps:clone" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="apps:clone"
[[ "$1" == "$cmd" ]] && shift 1
declare OLD_APP="$1" NEW_APP="$2"
local IGNORE_EXISTING=false
local SKIP_REBUILD=false
local IGNORE_EXISTING=false SKIP_REBUILD=false
for arg in "$@"; do
[[ "$arg" == "--skip-deploy" ]] && shift 1 && SKIP_REBUILD=true

View File

@@ -5,8 +5,11 @@ source "$PLUGIN_AVAILABLE_PATH/apps/functions"
cmd-apps-create() {
declare desc="creates app via command line"
local cmd="apps:create"
apps_create "$2"
declare cmd="apps:create"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
apps_create "$APP"
}
cmd-apps-create "$@"

View File

@@ -6,11 +6,14 @@ source "$PLUGIN_AVAILABLE_PATH/apps/functions"
cmd-apps-destroy() {
declare desc="destroys an app"
local cmd="apps:destroy"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ "$2" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory"
[[ "$3" == "force" ]] && export DOKKU_APPS_FORCE_DELETE=1
local APP="$2"
declare cmd="apps:destroy"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" FORCE="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ "$APP" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory"
[[ "$FORCE" == "force" ]] && export DOKKU_APPS_FORCE_DELETE=1
apps_destroy "$APP"
}

View File

@@ -5,7 +5,7 @@ source "$PLUGIN_AVAILABLE_PATH/apps/functions"
cmd-apps-exist() {
declare desc="checks if an app exists"
local cmd="apps:exists"
declare cmd="apps:exists"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"

View File

@@ -9,10 +9,9 @@ cmd-apps-lock() {
declare cmd="apps:lock"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
touch "$DOKKU_ROOT/$APP/.deploy.lock" || dokku_log_fail "Unable to create deploy lock"
dokku_log_info1 "Deploy lock created"
}

View File

@@ -9,6 +9,7 @@ cmd-apps-locked() {
declare cmd="apps:locked"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
local LOCKED="$(apps_is_locked "$APP")"

View File

@@ -7,11 +7,12 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions"
cmd-apps-rename() {
declare desc="renames an app"
local cmd="apps:rename"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$3" ]] && dokku_log_fail "Name is already taken"
local OLD_APP="$2"
local NEW_APP="$3"
declare cmd="apps:rename"
[[ "$1" == "$cmd" ]] && shift 1
declare OLD_APP="$1" NEW_APP="$2"
[[ -z "$OLD_APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$NEW_APP" ]] && dokku_log_fail "Name is already taken"
local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache"
local OLD_CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$OLD_APP/cache"