From 14a1d06c036ccbd43d9537ebd61341f5f193e2f5 Mon Sep 17 00:00:00 2001 From: Justin Clark Date: Tue, 15 Mar 2016 20:03:35 -0700 Subject: [PATCH] Collapse help into expandable command topics --- docs/development/plugin-creation.md | 25 +++++++++++++-- docs/development/plugin-triggers.md | 35 ++++++++++++++++----- docs/docker-options.md | 3 +- dokku | 49 ++++++++++++++++++++++++++--- plugins/00_dokku-standard/commands | 23 ++++++++++---- plugins/20_events/commands | 18 +++++++++-- plugins/apps/commands | 25 +++++++++++++-- plugins/certs/commands | 18 +++++++++-- plugins/checks/commands | 20 ++++++++++-- plugins/config/commands | 18 +++++++++-- plugins/docker-options/commands | 21 ++++++++++--- plugins/domains/commands | 18 +++++++++-- plugins/enter/commands | 18 +++++++++-- plugins/nginx-vhosts/commands | 18 +++++++++-- plugins/plugin/commands | 18 +++++++++-- plugins/proxy/commands | 18 +++++++++-- plugins/ps/commands | 18 +++++++++-- plugins/shell/commands | 20 ++++++++++-- plugins/storage/commands | 18 +++++++++-- plugins/tags/commands | 18 +++++++++-- plugins/tar/commands | 18 +++++++++-- 21 files changed, 379 insertions(+), 58 deletions(-) diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 8e66f37db..c08749d90 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -75,11 +75,30 @@ hello/commands set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in - help) - cat<, Says "Hello " hello:world, Says "Hello world" -EOF +help_content + } + + if [[ $1 = "hello:help" ]] ; then + echo -e 'Usage: dokku hello[:world] []' + echo '' + echo 'Say Hello World.' + echo '' + echo 'Example:' + echo '' + echo '$ dokku hello:world' + echo 'Hello world' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 00eafa59d..6d6e676f8 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -92,10 +92,10 @@ cd /root/dokku sudo BUILD_STACK=true make install ``` -### `commands help` +### `comands help` and `commands :help` -- Description: Used to aggregate all plugin `help` output. Your plugin should implement a `help` command in your `commands` file to take advantage of this plugin trigger. This must be implemented inside the `commands` plugin file. -- Invoked by: `dokku help` +- Description: Your plugin should implement a `help` command in your `commands` file to take advantage of this plugin trigger. `commands help` is used by `dokku help` to aggregate all plugins abbreviated `help` output. Implementing `:help` in your `commands` file gives users looking for help, a more detailed output. 'commands help' must be implemented inside the `commands` plugin file. It's recommended that `PLUGIN_NAME:help` be added to the commands file to ensure consistency among community plugins and give you a new avenue to share rich help content with your user. +- Invoked by: `dokku help` and `commands :help` - Arguments: None - Example: @@ -106,11 +106,30 @@ sudo BUILD_STACK=true make install set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in - help | derp:help) - cat<, Says "Hello " + hello:world, Says "Hello world" +help_content + } + + if [[ $1 = "hello:help" ]] ; then + echo -e 'Usage: dokku hello[:world] []' + echo '' + echo 'Say Hello World.' + echo '' + echo 'Example:' + echo '' + echo '$ dokku hello:world' + echo 'Hello world' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/docs/docker-options.md b/docs/docker-options.md index 88f8c3111..523e3eab3 100644 --- a/docs/docker-options.md +++ b/docs/docker-options.md @@ -5,8 +5,7 @@ Pass [options](https://docs.docker.com/engine/reference/run/) to Docker during Dokku's `build`, `deploy` and `run` phases ``` -docker-options Display app's Docker options for all phases -docker-options Display app's Docker options for phase (comma-separated phase list) +docker-options [phase(s)] Display app's Docker options for all phases (or comma separated phase list) docker-options:add OPTION Add Docker option to app for phase (comma-separated phase list) docker-options:remove OPTION Remove Docker option from app for phase (comma-separated phase list) ``` diff --git a/dokku b/dokku index 2c7abe1ee..b80742acc 100755 --- a/dokku +++ b/dokku @@ -157,13 +157,54 @@ execute_dokku_cmd() { case "$1" in help|'') + export LC_ALL=C # so sort will respect non alpha characters + ALL_PLUGIN_COMMANDS=$(find -L "$PLUGIN_PATH/enabled" -name commands 2> /dev/null || true) + + # build list of core plugin command files + for plugin_command in $ALL_PLUGIN_COMMANDS;do + if [[ "$(readlink -f "$plugin_command")" == *core-plugins* ]]; then + CORE_PLUGIN_COMMANDS+="$plugin_command " + fi + done + # build list of non-core plugin command files + for plugin_command in $ALL_PLUGIN_COMMANDS;do + if [[ "$(readlink -f "$plugin_command")" != *core-plugins* ]]; then + COMMUNITY_PLUGIN_COMMANDS+="$plugin_command " + fi + done + + # New lines are blank echos for readability echo "Usage: dokku [--quiet|--trace|--rm-container|--rm|--force] COMMAND [command-specific-options]" echo "" - echo "Options:" + echo "Primary help options, type \"dokku COMMAND:help\" for more details, or dokku help --all to see all commands." + echo "" + echo "Commands:" + echo "" - cat< , Run a command in the environment of an application trace [on/off], Enable dokku tracing url , Show the first URL for an application (compatibility) urls , Show all URLs for an application - version, Print dokku's version -EOF + version , Print dokku's version + help , Print the list of commands +help_content + } + + if [[ $help_topic ]] ; then + help_content_func | sed "/^\s*$help_topic\s/!d" | sort | sed '/^.*:/d' | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/20_events/commands b/plugins/20_events/commands index 07a975254..7bb735bfa 100755 --- a/plugins/20_events/commands +++ b/plugins/20_events/commands @@ -4,12 +4,26 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | events:help) - cat<, Create a new app apps:destroy , Permanently destroy an app apps:rename , Rename an app -EOF +help_content + } + + if [[ $1 = "apps:help" ]] ; then + echo -e 'Usage: dokku apps[:COMMAND]' + echo '' + echo 'List your apps.' + echo '' + echo 'Example:' + echo '' + echo '$ dokku apps' + echo '=====> My Apps' + echo 'example' + echo 'example2' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/certs/commands b/plugins/certs/commands index ed188e98b..c0fe3c526 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -4,7 +4,9 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | certs:help) - cat< CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate. certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) @@ -13,7 +15,19 @@ case "$1" in certs:remove , Remove an SSL Endpoint from an app. certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app. certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin -EOF +help_content + } + + if [[ $1 = "certs:help" ]] ; then + echo -e 'Usage: dokku certs:COMMAND' + echo '' + echo 'Manage Dokku apps SSL (TLS) certs.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/checks/commands b/plugins/checks/commands index 2f95816d0..efa774895 100755 --- a/plugins/checks/commands +++ b/plugins/checks/commands @@ -3,12 +3,26 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in - help | ps:help) - cat<, Show zero-downtime status checks:enable , Enable zero-downtime checks checks:disable , Disable zero-downtime checks -EOF +help_content + } + + if [[ $1 = "checks:help" ]] ; then + echo -e 'Usage: dokku checks[:COMAND]' + echo '' + echo 'Manage zero-downtime checks.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/config/commands b/plugins/config/commands index ddd9c0699..532d887b4 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -4,12 +4,26 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | config:help) - cat<|--global), Display all global or app-specific config vars config:get (|--global) KEY, Display a global or app-specific config value config:set (|--global) KEY1=VALUE1 [KEY2=VALUE2 ...], Set one or more config vars config:unset (|--global) KEY1 [KEY2 ...], Unset one or more config vars -EOF +help_content + } + + if [[ $1 = "config:help" ]] ; then + echo -e 'Usage: dokku config[:COMMAND] (|--global)' + echo '' + echo 'Manage global or app-specific config vars.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index 5c934c8d5..65303d197 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -4,12 +4,25 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | docker-options:help) - cat<, Display app's Docker options for all phases - docker-options , Display app's Docker options for phase (comma separated phase list) + help_content_func () { + declare desc="return help_content string" + cat< [phase(s)], Display app's Docker options for all phases (or comma separated phase list) docker-options:add OPTION, Add Docker option to app for phase (comma separated phase list) docker-options:remove OPTION, Remove Docker option from app for phase (comma separated phase list) -EOF +help_content + } + + if [[ $1 = "docker-options:help" ]] ; then + echo -e 'Usage: dokku docker-options[:COMMAND]' + echo '' + echo 'Display app'"'"'s Docker options for all phases.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/domains/commands b/plugins/domains/commands index 72e869845..abb2aa062 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -4,7 +4,9 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | domains:help) - cat<], List domains domains:add DOMAIN, Add a domain to app domains:clear , Clear all domains for app @@ -12,7 +14,19 @@ case "$1" in domains:enable , Enable VHOST support domains:remove DOMAIN, Remove a domain from app domains:set-global , Set global domain name -EOF +help_content + } + + if [[ $1 = "domains:help" ]] ; then + echo -e 'Usage: dokku domains[:COMMAND]' + echo '' + echo 'Manage vhost domains used by the Dokku proxy.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/enter/commands b/plugins/enter/commands index 94709c05e..685ba63f8 100755 --- a/plugins/enter/commands +++ b/plugins/enter/commands @@ -4,9 +4,23 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | enter:help) - cat< [ || --container-id ], Connect to a specific app container -EOF +help_content + } + + if [[ $1 = "enter:help" ]] ; then + echo -e 'Usage: dokku enter ' + echo '' + echo 'Allows you to access a bash prompt inside the container of the app.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index ef0100b77..7c3f6cbd8 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -4,11 +4,25 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | nginx:help) - cat<, (Re)builds nginx config for given app nginx:access-logs [-t], Show the nginx access logs for an application (-t follows) nginx:error-logs [-t], Show the nginx error logs for an application (-t follows) -EOF +help_content + } + + if [[ $1 = "nginx:help" ]] ; then + echo -e 'Usage: dokku nginx[:COMMAND]' + echo '' + echo 'Interact with Dokkus Nginx proxy.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/plugin/commands b/plugins/plugin/commands index d331361df..c2c16ac62 100755 --- a/plugins/plugin/commands +++ b/plugins/plugin/commands @@ -4,7 +4,9 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | plugin:help) - cat<, Enable a previously disabled plugin plugin:disable , Disable an installed plugin (third-party only) plugin:uninstall , Uninstall a plugin (third-party only) -EOF +help_content + } + + if [[ $1 = "plugin:help" ]] ; then + echo -e 'Usage: dokku plugin[:COMMAND]' + echo '' + echo 'View installed plugins and manage community plugins.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/proxy/commands b/plugins/proxy/commands index 00337fbab..5aa4e3b72 100755 --- a/plugins/proxy/commands +++ b/plugins/proxy/commands @@ -4,12 +4,26 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | proxy:help) - cat<, Show proxy for app proxy:enable , Enable proxy for app proxy:disable , Disable proxy for app proxy:set , NOT IMPLEMENTED YET!! -EOF +help_content + } + + if [[ $1 = "proxy:help" ]] ; then + echo -e 'Usage: dokku proxy[:COMMAND]' + echo '' + echo 'Control the proxy used by dokku, per app.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/ps/commands b/plugins/ps/commands index a445b22fd..8ed02d044 100755 --- a/plugins/ps/commands +++ b/plugins/ps/commands @@ -4,7 +4,9 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | ps:help) - cat<, List processes running in app container(s) ps:scale [ = [=]], Get/Set how many instances of a given process to run ps:start , Start app container(s) @@ -14,7 +16,19 @@ case "$1" in ps:restart , Restart app container(s) ps:restartall, Restart all deployed app containers ps:restore, Start previously running apps e.g. after reboot -EOF +help_content + } + + if [[ $1 = "ps:help" ]] ; then + echo -e 'Usage: dokku ps[:COMMAND]' + echo '' + echo 'List running processes in container, and restart app.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/shell/commands b/plugins/shell/commands index 361a41d56..341904954 100755 --- a/plugins/shell/commands +++ b/plugins/shell/commands @@ -4,9 +4,25 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | shell:help) - cat<, List bind mounts for app's container(s) (host:container) storage:mount , Create a new bind mount storage:unmount , Remove an existing bind mount -EOF +help_content + } + + if [[ $1 = "shell:help" ]] ; then + echo -e 'Usage: dokku storage:COMMAND' + echo '' + echo 'Mount local volume / directories inside containers.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/tags/commands b/plugins/tags/commands index 8dc78b2be..281155bd9 100755 --- a/plugins/tags/commands +++ b/plugins/tags/commands @@ -4,12 +4,26 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | tags:help) - cat<, List all app image tags tags:create , Add tag to latest running app image tags:deploy , Deploy tagged app image tags:destroy , Remove app image tag -EOF +help_content + } + + if [[ $1 = "tags:help" ]] ; then + echo -e 'Usage: dokku tags[:COMMAND]' + echo '' + echo 'Manage docker image tags.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *) diff --git a/plugins/tar/commands b/plugins/tar/commands index c83149ba5..8a197cce0 100755 --- a/plugins/tar/commands +++ b/plugins/tar/commands @@ -4,10 +4,24 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | tar:help) - cat<, Reads an tarball containing the app from stdin tar:from , Loads an app tarball from url. -EOF +help_content + } + + if [[ $1 = "tar:help" ]] ; then + echo -e 'Usage: dokku tar[:COMMAND]' + echo '' + echo 'An alternative to using git, apps are loaded via tarballs instead.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, + else + help_content_func + fi ;; *)