refactor: standardize help generation

This commit is contained in:
Jose Diaz-Gonzalez
2020-02-10 00:37:00 -05:00
parent be5ea845fc
commit ef7894fdfa
67 changed files with 816 additions and 603 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/help-functions"
case "$1" in
help | scheduler-docker-local:help)

View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-scheduler-docker-local-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="scheduler-docker-local"
local plugin_description="Manage the docker-local scheduler integration for an app"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
scheduler-docker-local:report [<app>] [<flag>], Displays a scheduler-docker-local report for one or more apps
scheduler-docker-local:set <app> <property> (<value>), Set or clear a scheduler-docker-local property for an app
help_content
}

View File

@@ -65,32 +65,6 @@ cmd-scheduler-docker-local-report-single() {
fi
}
scheduler_docker_local_help_content_func() {
declare desc="return scheduler-docker-local plugin help content"
cat <<help_content
scheduler-docker-local:report [<app>] [<flag>], Displays a scheduler-docker-local report for one or more apps
scheduler-docker-local:set <app> <property> (<value>), Set or clear a scheduler-docker-local property for an app
help_content
}
cmd-scheduler-docker-local-help() {
if [[ $1 == "scheduler-docker-local:help" ]]; then
echo -e 'Usage: dokku scheduler-docker-local[:COMMAND]'
echo ''
echo 'Manages the scheduler-docker-local integration for an app.'
echo ''
echo 'Additional commands:'
scheduler_docker_local_help_content_func | sort | column -c2 -t -s,
echo ''
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
scheduler_docker_local_help_content_func
else
cat <<help_desc
scheduler-docker-local, Manages the scheduler-docker-local integration for an app
help_desc
fi
}
fn-scheduler-docker-local-retire-container() {
declare APP="$1" CID="$2" DEAD_TIME="$3"
local STATE

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/help-functions"
cmd-scheduler-docker-local-help "scheduler-docker-local:help"