From 31947b470289c42641b917ea210c8239b9dd9472 Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Sat, 10 Aug 2019 22:28:58 -0400 Subject: [PATCH] Add the "actions" action To list the available actions of psu --- psu | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/psu b/psu index e9dea79..3749ea2 100644 --- a/psu +++ b/psu @@ -26,7 +26,7 @@ set -e ############################ main() { VERSION="0.2.0-alpha.2" - ACTIONS="deploy undeploy list info status services tasks tasks:healthy containers help version" + ACTIONS="deploy undeploy list info status services tasks tasks:healthy containers actions help version" set_globals "$@" @@ -423,16 +423,25 @@ inputs() { shift fi ;; + actions) + ACTION="actions" + echo "Portainer Stack Utils, version $VERSION" + echo "" + echo "Available actions:" + for action in $ACTIONS; do + echo " $action" + done + exit 0 + ;; -V|--version|version) - local message - local version_message - message="Portainer Stack Utils, version $VERSION - License GPLv3: GNU GPL version 3" - version_message="$(input_message "$1" "$message")" - if [ -n "$version_message" ]; then + if [ -z "$ACTION" ]; then ACTION="version" - echo "$version_message" + echo "Portainer Stack Utils, version $VERSION + License GPLv3: GNU GPL version 3" exit 0 + else + input_error "Error: invalid option '$1' for the '$ACTION' action" + exit 1 fi ;; -h|--help|help) @@ -507,7 +516,7 @@ inputs() { exit 1 fi else - input_error "Error: Invalid argument: '$1', run the 'psu help' command for more information" + input_error "Error: Unknown action '$1', run the 'psu help' command for more information" exit 1 fi esac @@ -585,20 +594,6 @@ input_flag() { fi } -input_message() { - local option - local value - option="$1" - value="$2" - - if [ -z "$ACTION" ]; then - echo "$value" - else - input_error "Error: invalid option '$option' for the '$ACTION' action" - exit 1 - fi -} - input_error() { local message if [ -n "$1" ]; then