Move config arg parsing into config/functions

This commit is contained in:
Jose Diaz-Gonzalez
2015-08-31 23:03:52 -04:00
parent e08f02aca7
commit 99f1f1b6d3
2 changed files with 35 additions and 34 deletions

View File

@@ -15,3 +15,33 @@ config_export() {
echo "$VARS" | awk '{print "export " $0}'
return 0
}
config_parse_args() {
case "$2" in
--global)
ENV_FILE="$DOKKU_ROOT/ENV"
DOKKU_CONFIG_TYPE="global"
DOKKU_CONFIG_RESTART=false
;;
--no-restart)
APP="$3"
ENV_FILE="$DOKKU_ROOT/$APP/ENV"
DOKKU_CONFIG_RESTART=false
DOKKU_CONFIG_TYPE="app"
set -- "${@:1:1}" "${@:3}"
esac
APP=${APP:="$2"}
ENV_FILE=${ENV_FILE:="$DOKKU_ROOT/$APP/ENV"}
DOKKU_CONFIG_TYPE=${DOKKU_CONFIG_TYPE:="app"}
DOKKU_CONFIG_RESTART=${DOKKU_CONFIG_RESTART:=true}
if [[ "$DOKKU_CONFIG_TYPE" = "app" ]]; then
if [[ -z $APP ]]; then
echo "Please specify an app to run the command on" >&2 && exit 1
else
verify_app_name "$2"
fi
fi
export APP ENV_FILE DOKKU_CONFIG_TYPE DOKKU_CONFIG_RESTART
}