From a09560542bfac3554d6efb20148fda8f65003010 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 20 Feb 2017 20:08:38 -0700 Subject: [PATCH 1/2] refactor: move ssh-keys:help to internal-functions --- plugins/ssh-keys/commands | 22 ++-------------------- plugins/ssh-keys/internal-functions | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 20 deletions(-) create mode 100755 plugins/ssh-keys/internal-functions diff --git a/plugins/ssh-keys/commands b/plugins/ssh-keys/commands index bfd36a0ce..1aabfd445 100755 --- a/plugins/ssh-keys/commands +++ b/plugins/ssh-keys/commands @@ -1,29 +1,11 @@ #!/usr/bin/env bash [[ " help ssh-keys:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | ssh-keys:help) - help_content_func () { - declare desc="return ssh-keys plugin help content" - cat< [/path/to/key], Add a new public key by pipe or path - ssh-keys:remove , Remove SSH public key by name -help_content - } - - if [[ $1 = "ssh-keys:help" ]] ; then - echo -e 'Usage: dokku ssh-keys[:COMMAND]' - echo '' - echo 'Manage public ssh keys that are allowed to connect to Dokku' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + ssh_keys_help_cmd "$@" ;; *) diff --git a/plugins/ssh-keys/internal-functions b/plugins/ssh-keys/internal-functions new file mode 100755 index 000000000..bc4d868e7 --- /dev/null +++ b/plugins/ssh-keys/internal-functions @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +ssh_keys_help_content_func() { + declare desc="return ssh-keys plugin help content" + cat< [/path/to/key], Add a new public key by pipe or path + ssh-keys:remove , Remove SSH public key by name +help_content +} + +ssh_keys_help_cmd() { + if [[ $1 = "ssh-keys:help" ]] ; then + echo -e 'Usage: dokku ssh-keys[:COMMAND]' + echo '' + echo 'Manage public ssh keys that are allowed to connect to Dokku' + echo '' + echo 'Additional commands:' + ssh_keys_help_content_func | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + ssh_keys_help_content_func + else + cat< Date: Mon, 20 Feb 2017 20:09:09 -0700 Subject: [PATCH 2/2] refactor: alias ssh-keys:default to ssh-keys:help --- plugins/ssh-keys/subcommands/default | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) mode change 100644 => 100755 plugins/ssh-keys/subcommands/default diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default old mode 100644 new mode 100755 index abdbaa619..20fea35c3 --- a/plugins/ssh-keys/subcommands/default +++ b/plugins/ssh-keys/subcommands/default @@ -1,12 +1,5 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions" -ssh_keys_main_cmd() { - declare desc="an alias for ssh-keys:list" - local cmd="ssh-keys" - list_ssh_keys -} - -ssh_keys_main_cmd "$@" \ No newline at end of file +ssh_keys_help_cmd "$@"