From 76e27f03335066d734116fddd649171c7991d023 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 10 Jan 2016 14:05:33 -0500 Subject: [PATCH] Add support for --app flag. Refs #1638 This change sets a DOKKU_APP_NAME env var, which can be used by plugins as a replacement for the `app` param if specified. Note that each plugin will have to manually shift it's arguments if necessary --- dokku | 4 +++- plugins/common/functions | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dokku b/dokku index dec208114..e96f0db2f 100755 --- a/dokku +++ b/dokku @@ -47,7 +47,9 @@ parse_args "$@" args=("$@") if [[ "${args[0]}" =~ ^--.* ]]; then for arg in "$@"; do - if [[ "$arg" =~ ^--.* ]]; then + if [[ "$arg" == "--app" ]]; then + shift 2 + elif [[ "$arg" =~ ^--.* ]]; then shift 1 else break diff --git a/plugins/common/functions b/plugins/common/functions index d32c5f8ad..9d6f0f3eb 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -196,7 +196,9 @@ is_abs_path() { } parse_args() { + local next_index=1; local skip=false; local args=("$@") for arg in "$@"; do + $skip && skip=false && continue case "$arg" in --quiet) export DOKKU_QUIET_OUTPUT=1 @@ -210,7 +212,11 @@ parse_args() { --force) export DOKKU_APPS_FORCE_DELETE=1 ;; + --app) + export DOKKU_APP_NAME=${args[$next_index]}; skip=true + ;; esac + next_index=$(( next_index + 1 )) done return 0 }