From 9614f7dca26819de7ea4d0e784fe668e3af82631 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 20 Feb 2017 17:18:29 -0700 Subject: [PATCH 1/3] feat: implement apps:list Also deprecate the `apps` command in favor of `apps:list` --- plugins/apps/commands | 3 ++- plugins/apps/internal-functions | 14 ++++++++++++++ plugins/apps/subcommands/default | 16 +++------------- plugins/apps/subcommands/list | 5 +++++ 4 files changed, 24 insertions(+), 14 deletions(-) create mode 100755 plugins/apps/internal-functions create mode 100755 plugins/apps/subcommands/list diff --git a/plugins/apps/commands b/plugins/apps/commands index 97b8fae13..d6a140f4b 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -7,10 +7,11 @@ case "$1" in help_content_func () { declare desc="return apps plugin help content" cat< , Clones an app apps:create , Create a new app apps:destroy , Permanently destroy an app + apps:list, List your apps apps:rename , Rename an app apps:report [] [], Display report about an app help_content diff --git a/plugins/apps/internal-functions b/plugins/apps/internal-functions new file mode 100755 index 000000000..1374bda6b --- /dev/null +++ b/plugins/apps/internal-functions @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" + +apps_list_cmd() { + declare desc="lists all apps" + local cmd="apps" + local app + + dokku_log_info2_quiet "My Apps" + for app in $(dokku_apps); do + echo "$app" + done +} diff --git a/plugins/apps/subcommands/default b/plugins/apps/subcommands/default index 47f5973a6..ac2c04ed3 100755 --- a/plugins/apps/subcommands/default +++ b/plugins/apps/subcommands/default @@ -1,16 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" -apps_main_cmd() { - declare desc="lists all apps" - local cmd="apps" - local app - - dokku_log_info2_quiet "My Apps" - for app in $(dokku_apps); do - echo "$app" - done -} - -apps_main_cmd "$@" +dokku_log_warn "Deprecated: Please use apps:list" +apps_list_cmd "$@" diff --git a/plugins/apps/subcommands/list b/plugins/apps/subcommands/list new file mode 100755 index 000000000..b9573fac2 --- /dev/null +++ b/plugins/apps/subcommands/list @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" + +apps_list_cmd "$@" From cd3e637387d1560ea3c9f5465e42fb065dc66642 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 20 Feb 2017 17:22:41 -0700 Subject: [PATCH 2/3] refactor: move apps:help to internal-functions --- plugins/apps/commands | 32 ++-------------------------- plugins/apps/internal-functions | 37 +++++++++++++++++++++++++++++++++ plugins/apps/subcommands/report | 2 +- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/plugins/apps/commands b/plugins/apps/commands index d6a140f4b..84cd4b172 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -1,39 +1,11 @@ #!/usr/bin/env bash [[ " help apps:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | apps:help) - help_content_func () { - declare desc="return apps plugin help content" - cat< , Clones an app - apps:create , Create a new app - apps:destroy , Permanently destroy an app - apps:list, List your apps - apps:rename , Rename an app - apps:report [] [], Display report about an app -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 + apps_help_cmd "$@" ;; *) diff --git a/plugins/apps/internal-functions b/plugins/apps/internal-functions index 1374bda6b..274132560 100755 --- a/plugins/apps/internal-functions +++ b/plugins/apps/internal-functions @@ -2,6 +2,43 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +apps_help_content_func() { + declare desc="return apps plugin help content" + cat< , Clones an app + apps:create , Create a new app + apps:destroy , Permanently destroy an app + apps:list, List your apps + apps:rename , Rename an app + apps:report [] [], Display report about an app +help_content +} + +apps_help_cmd() { + if [[ $1 = "apps:help" ]] ; then + echo -e 'Usage: dokku apps[:COMMAND]' + echo '' + echo 'Manage Dokku apps' + echo '' + echo 'Example:' + echo '' + echo '$ dokku apps' + echo '=====> My Apps' + echo 'example' + echo 'example2' + echo '' + echo 'Additional commands:' + apps_help_content_func | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + apps_help_content_func + else + cat< Date: Mon, 20 Feb 2017 17:24:09 -0700 Subject: [PATCH 3/3] cleanup: move from apps to apps:list subcommand for tests and docs --- docs/deployment/application-management.md | 11 +++++++---- tests/unit/10_apps.bats | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/deployment/application-management.md b/docs/deployment/application-management.md index 679246815..27d220af8 100644 --- a/docs/deployment/application-management.md +++ b/docs/deployment/application-management.md @@ -3,10 +3,10 @@ > New as of 0.3.1 ``` -apps # List your apps apps:clone # Clones an app apps:create # Create a new app apps:destroy # Permanently destroy an app +apps:list # List your apps apps:rename # Rename an app apps:report [] [] # Display report about an app ``` @@ -15,10 +15,12 @@ apps:report [] [] # Display report about an app ### Listing Applications -You can easily list all available applications using the `apps` command: +> New as of 0.8.1. Use the `apps` command for older versions. + +You can easily list all available applications using the `apps:list` command: ```shell -dokku apps +dokku apps:list ``` ``` @@ -30,7 +32,7 @@ python-app Note that you can easily hide extra output from Dokku commands by using the `--quiet` flag, which makes it easier to parse on the command-line. ```shell -dokku --quiet apps +dokku --quiet apps:list ``` ``` @@ -179,6 +181,7 @@ dokku apps:report node-js-sample ``` You can pass flags which will output only the value of the specific information you want. For example: + ```shell dokku apps:report node-js-sample --git-sha ``` diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index 17ed29be3..797304716 100644 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -15,7 +15,7 @@ teardown () { echo "output: "$output echo "status: "$status assert_success - run bash -c "dokku apps | grep $TEST_APP" + run bash -c "dokku apps:list | grep $TEST_APP" echo "output: "$output echo "status: "$status assert_output $TEST_APP @@ -36,7 +36,7 @@ teardown () { echo "output: "$output echo "status: "$status assert_success - run bash -c "dokku apps | grep $TEST_APP" + run bash -c "dokku apps:list | grep $TEST_APP" echo "output: "$output echo "status: "$status assert_output $TEST_APP @@ -64,7 +64,7 @@ teardown () { echo "output: "$output echo "status: "$status assert_success - run bash -c "dokku apps | grep $TEST_APP" + run bash -c "dokku apps:list | grep $TEST_APP" echo "output: "$output echo "status: "$status assert_output "" @@ -97,7 +97,7 @@ teardown () { echo "output: "$output echo "status: "$status assert_success - run bash -c "dokku apps | grep $TEST_APP" + run bash -c "dokku apps:list | grep $TEST_APP" echo "output: "$output echo "status: "$status assert_success