-
Notifications
You must be signed in to change notification settings - Fork 140
/
parse-params.sh
66 lines (62 loc) · 1.22 KB
/
parse-params.sh
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
64
65
66
#!/bin/bash
parse_params() {
update_images=false
remove_volumes=false
no_connectors=false
connectors_only=false
bypass_config=false
reset_config=-false
use_snapshot=true
watch_logs=false
#Boilerplate parameter parsing
PARAMS=""
while (( "$#" )); do
case "$1" in
-n|--no-connectors)
no_connectors=true
shift 1
;;
-x|--no-configuration)
bypass_config=true
shift 1
;;
-c|--connectors-only)
connectors_only=true
shift 1
;;
-u|--update-images)
update_images=true
shift 1
;;
-v|--remove-volumes)
remove_volumes=true
shift 1
;;
-r|--reset-configuration)
reset_config=true
shift 1
;;
-s|--no-snapshot)
use_snapshot=false
shift 1
;;
-w|--watch-logs)
watch_logs=true
shift 1
;;
--) # end argument parsing
shift
break
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done
parsed_params=$PARAMS
}