From d001fcc89609b7d69f5358d5330cf5cb464e2796 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Mon, 28 Nov 2016 02:53:46 +0000 Subject: [PATCH] Added certs default help function --- plugins/certs/commands | 23 +++-------------------- plugins/certs/functions | 24 ++++++++++++++++++++++++ plugins/certs/subcommands/default | 13 +++++++++++++ 3 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 plugins/certs/subcommands/default diff --git a/plugins/certs/commands b/plugins/certs/commands index c34b902c8..e04a558a3 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -1,31 +1,14 @@ #!/usr/bin/env bash [[ " help certs:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/certs/functions" case "$1" in help | certs:help) - help_content_func () { - declare desc="return certs plugin help content" - 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) - certs:info , Show certificate information for an ssl endpoint - certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate - 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 -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, + help_formatted else help_content_func fi diff --git a/plugins/certs/functions b/plugins/certs/functions index a130c993e..77d10de83 100755 --- a/plugins/certs/functions +++ b/plugins/certs/functions @@ -2,6 +2,30 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +help_formatted (){ + 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, +} + +help_content_func () { + declare desc="return certs plugin help content" + 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) + certs:info , Show certificate information for an ssl endpoint + certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate + 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 +help_content + } + is_ssl_enabled() { declare desc="returns 0 if ssl is enabled for given app" local APP=$1; verify_app_name "$APP" diff --git a/plugins/certs/subcommands/default b/plugins/certs/subcommands/default new file mode 100644 index 000000000..f9869973a --- /dev/null +++ b/plugins/certs/subcommands/default @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/certs/functions" + +certs_main_cmd() { + declare desc="return certs plugin help content" + local cmd="certs" + help_formatted +} + +certs_main_cmd "$@" +