-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathoptions.sh
More file actions
65 lines (57 loc) · 2.22 KB
/
options.sh
File metadata and controls
65 lines (57 loc) · 2.22 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
58
59
60
61
62
63
# Generated by stubbs:add-option. Do not edit, if using stubbs.
# Created: Wed Aug 5 14:11:16 MDT 2015
#
#/ usage: accept:upgrade --provider <vagrant> --from <> [ --to <master>] [ --skip-cleanup <false>] --upgrade-style <graceful>
# _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 ;;
--from) rerun_option_check $# $1; FROM=$2 ; shift ;;
--to) rerun_option_check $# $1; TO=$2 ; shift ;;
--skip-cleanup) rerun_option_check $# $1; SKIP_CLEANUP=$2 ; shift ;;
--upgrade-style) rerun_option_check $# $1; UPGRADE_STYLE=$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 "$TO" ] && TO="$(rerun_property_get $RERUN_MODULE_DIR/options/to DEFAULT)"
[ -z "$SKIP_CLEANUP" ] && SKIP_CLEANUP="$(rerun_property_get $RERUN_MODULE_DIR/options/skip-cleanup DEFAULT)"
[ -z "$UPGRADE_STYLE" ] && UPGRADE_STYLE="$(rerun_property_get $RERUN_MODULE_DIR/options/upgrade-style DEFAULT)"
# Check required options are set
[ -z "$PROVIDER" ] && { echo >&2 "missing required option: --provider" ; return 2 ; }
[ -z "$FROM" ] && { echo >&2 "missing required option: --from" ; return 2 ; }
[ -z "$UPGRADE_STYLE" ] && { echo >&2 "missing required option: --upgrade-style" ; return 2 ; }
# If option variables are declared exportable, export them.
#
return 0
}
# If not already set, initialize the options variables to null.
: ${PROVIDER:=}
: ${FROM:=}
: ${TO:=}
: ${SKIP_CLEANUP:=}
: ${UPGRADE_STYLE:=}