Commit 62b6917b authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Refactor how option arguments are disabled

parent ff1318ab
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ test -e ${CONFIG_FILE} &&
	source ${CONFIG_FILE}


declare -ra OPTIONS=( DESCRIPTION COORDINATOR_URL )

usage() {
	tee <<-END
	Usage:
@@ -74,22 +76,28 @@ config_help() {
	END
}

is_declared() { declare -p $1 &>/dev/null || return 1; }


case ${1-} in
	unregister)
		shift
		COMMAND=unregister
		ARGUMENTS=( RUNNER_NAME )
		# Disable flags not allowed for unregister
		declare -r DESCRIPTION COORDINATOR_URL
		;;
	register) shift ;&
	*)
		COMMAND=register
		ARGUMENTS=( TOKEN NAME )
		declare -g DESCRIPTION COORDINATOR_URL
		;;
esac

# Disable any option var that has not been declared
# If it's command line flag is found an error will be raised
for opt in "${OPTIONS[@]}"; do
	is_declared $opt || declare -r $opt
done

offset=0
while [[ $# -gt 0 ]]; do