summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-05-02 18:18:49 +0100
committerLyndon Brown <jnqnfe@gmail.com>2020-05-02 18:18:49 +0100
commit22d8ac15dbc75af2acf02447cf045791b137d7d4 (patch)
treeb86b7f8594da58b7b336d97c1d382ce831994df6 /functions
parent55e17b1e256a4295c67f44e633adaa07f850d4fb (diff)
downloadvyos-live-build-22d8ac15dbc75af2acf02447cf045791b137d7d4.tar.gz
vyos-live-build-22d8ac15dbc75af2acf02447cf045791b137d7d4.zip
options: de-duplicate common option handling
Diffstat (limited to 'functions')
-rwxr-xr-xfunctions/arguments.sh108
1 files changed, 57 insertions, 51 deletions
diff --git a/functions/arguments.sh b/functions/arguments.sh
index c40bab4ca..a17cf3c1e 100755
--- a/functions/arguments.sh
+++ b/functions/arguments.sh
@@ -28,60 +28,11 @@ Arguments ()
while true
do
case "${1}" in
- --breakpoints)
- _BREAKPOINTS="true"
+ --breakpoints|--color|--debug|--force|-h|--help|--no-color|--quiet|-u|--usage|--verbose|-v|--version)
+ Handle_common_option "${1}"
shift
;;
- --color)
- _COLOR="true"
- _COLOR_OUT="true"
- _COLOR_ERR="true"
- shift
- ;;
-
- --no-color)
- _COLOR="false"
- _COLOR_OUT="false"
- _COLOR_ERR="false"
- shift
- ;;
-
- --debug)
- _DEBUG="true"
- shift
- ;;
-
- --force)
- _FORCE="true"
- shift
- ;;
-
- -h|--help)
- Man
- shift
- ;;
-
- --quiet)
- _QUIET="true"
- shift
- ;;
-
- -u|--usage)
- Usage --exit
- shift
- ;;
-
- --verbose)
- _VERBOSE="true"
- shift
- ;;
-
- -v|--version)
- echo "${VERSION}"
- exit 0
- ;;
-
--)
shift
break
@@ -94,3 +45,58 @@ Arguments ()
esac
done
}
+
+Handle_common_option ()
+{
+ case "${1}" in
+ --breakpoints)
+ _BREAKPOINTS="true"
+ ;;
+
+ --color)
+ _COLOR="true"
+ _COLOR_OUT="true"
+ _COLOR_ERR="true"
+ ;;
+
+ --no-color)
+ _COLOR="false"
+ _COLOR_OUT="false"
+ _COLOR_ERR="false"
+ ;;
+
+ --debug)
+ _DEBUG="true"
+ ;;
+
+ --force)
+ _FORCE="true"
+ ;;
+
+ -h|--help)
+ Man
+ ;;
+
+ --quiet)
+ _QUIET="true"
+ ;;
+
+ -u|--usage)
+ Usage --exit
+ ;;
+
+ --verbose)
+ _VERBOSE="true"
+ ;;
+
+ -v|--version)
+ echo "${VERSION}"
+ exit 0
+ ;;
+
+ *)
+ Echo_error "Internal error: Unknown common option '%s'" "${1}"
+ exit 1
+ ;;
+ esac
+}