File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -6,36 +6,52 @@ Takes arguments passed in nearly any format to a bash script and allows easy acc
66
77### Get An Arguments Value
88
9- Get the value of the ` --debug 3 ` flag
10-
119``` bash
12- DEBUG=" ${args['debug']} " # 3
10+
11+ # -a "some text"
12+ if [ " $( argValue " a" ) " == ' some text' ]; then
13+ # Do something awesome
14+ fi
15+
16+ # --debug 3
17+ DEBUG_LEVEL=" $( argValue " debug" ) " # 3
18+
19+ # -R 0
20+ [ " $( argValue " R" ) " == " 0" ] && echo " Recursive depth 0"
21+
22+ # -aXb 'cookie'
23+ BISCUIT=" $( argValue " b" ) " # 'cookie'
24+
1325```
1426
1527### Check If An Argument Has Been Passed
1628
1729Check for the ` -v ` flag
1830
1931``` bash
32+
2033 if argExists ' v' ; then
2134 echo " The -v flag has been passed"
2235 fi
2336
2437 # Or
2538
2639 argExists ' v' && echo " Verbosity Enabled"
40+
2741```
2842
2943Check for the ` --test ` flag
3044
3145``` bash
46+
3247 if argExists ' test' ; then
3348 echo " The --test flag has been passed"
3449 fi
3550
3651 # Or
3752
3853 argExists ' test' && echo " Testing enabled"
54+
3955```
4056
4157## Supported Argument Formats
You can’t perform that action at this time.
0 commit comments