Skip to content

Commit 0d44cfb

Browse files
committed
Added better examples of getting a value
1 parent f639f4e commit 0d44cfb

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff 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

1729
Check 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

2943
Check 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

0 commit comments

Comments
 (0)