-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathoptions.sh
More file actions
59 lines (51 loc) · 1.83 KB
/
options.sh
File metadata and controls
59 lines (51 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Generated by stubbs:add-option. Do not edit, if using stubbs.
# Created: Thu Jul 23 11:38:40 MDT 2015
#
#/ usage: tests:provision --provider <vagrant> --version <dev> [ --skip-cleanup <false>]
# _rerun_options_parse_ - Parse the command arguments and set option variables.
#
# rerun_options_parse "$@"
#
# Arguments:
#
# * the command options and their arguments
#
# Notes:
#
# * Sets shell variables for any parsed options.
# * The "-?" help argument prints command usage and will exit 2.
# * Return 0 for successful option parse.
#
rerun_options_parse() {
while [ "$#" -gt 0 ]; do
OPT="$1"
case "$OPT" in
--provider) rerun_option_check $# $1; PROVIDER=$2 ; shift ;;
--version) rerun_option_check $# $1; VERSION=$2 ; shift ;;
--skip-cleanup) rerun_option_check $# $1; SKIP_CLEANUP=$2 ; shift ;;
# help option
-|--*?)
rerun_option_usage
exit 2
;;
# end of options, just arguments left
*)
break
esac
shift
done
# Set defaultable options.
[ -z "$PROVIDER" ] && PROVIDER="$(rerun_property_get $RERUN_MODULE_DIR/options/provider DEFAULT)"
[ -z "$VERSION" ] && VERSION="$(rerun_property_get $RERUN_MODULE_DIR/options/version DEFAULT)"
[ -z "$SKIP_CLEANUP" ] && SKIP_CLEANUP="$(rerun_property_get $RERUN_MODULE_DIR/options/skip-cleanup DEFAULT)"
# Check required options are set
[ -z "$PROVIDER" ] && { echo >&2 "missing required option: --provider" ; return 2 ; }
[ -z "$VERSION" ] && { echo >&2 "missing required option: --version" ; return 2 ; }
# If option variables are declared exportable, export them.
#
return 0
}
# If not already set, initialize the options variables to null.
: ${PROVIDER:=}
: ${VERSION:=}
: ${SKIP_CLEANUP:=}