refactor: standardize help generation
This commit is contained in:
@@ -3,6 +3,7 @@ set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/help-functions"
|
||||
|
||||
case "$1" in
|
||||
git-hook)
|
||||
|
||||
34
plugins/git/help-functions
Executable file
34
plugins/git/help-functions
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-help() {
|
||||
declare desc="help command"
|
||||
declare CMD="$1"
|
||||
local plugin_name="git"
|
||||
local plugin_description="Manage app deploys via git"
|
||||
|
||||
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
|
||||
git:initialize <app>, Initialize a git repository for an app
|
||||
git:report [<app>] [<flag>], Displays a git report for one or more apps
|
||||
git:set <app> <property> (<value>), Set or clear a git property for an app
|
||||
help_content
|
||||
}
|
||||
@@ -66,30 +66,3 @@ cmd-git-report-single() {
|
||||
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
||||
fi
|
||||
}
|
||||
|
||||
git_help_content_func() {
|
||||
declare desc="return git plugin help content"
|
||||
cat <<help_content
|
||||
git:initialize <app>, Initialize a git repository for an app
|
||||
git:report [<app>] [<flag>], Displays a git report for one or more apps
|
||||
git:set <app> <property> (<value>), Set or clear a git property for an app
|
||||
help_content
|
||||
}
|
||||
|
||||
cmd-git-help() {
|
||||
if [[ $1 == "git:help" ]]; then
|
||||
echo -e 'Usage: dokku git[:COMMAND]'
|
||||
echo ''
|
||||
echo 'Manages the git integration for an app.'
|
||||
echo ''
|
||||
echo 'Additional commands:'
|
||||
git_help_content_func | sort | column -c2 -t -s,
|
||||
echo ''
|
||||
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||
git_help_content_func
|
||||
else
|
||||
cat <<help_desc
|
||||
git, Manages the git integration for an app
|
||||
help_desc
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/help-functions"
|
||||
|
||||
cmd-git-help "git:help"
|
||||
|
||||
Reference in New Issue
Block a user