Skip to content

Commit fc05af8

Browse files
committed
Added crude argument listing functionality
1 parent 2dae05e commit fc05af8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

argument-parser.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,18 @@ argGetName() {
7474
}
7575

7676
argList() {
77+
echo "ARGUMENTS:"
78+
for arguments in "${!argExpected[@]}"
79+
do
80+
81+
regexArgName="(.+) - (.+)"
82+
[[ "${argExpected[$arguments]}" =~ $regexArgName ]]
7783

84+
local argumentName="${BASH_REMATCH[1]}"
85+
local argumentDesc="${BASH_REMATCH[2]}"
86+
echo " $arguments ($argumentName)"
87+
echo " $argumentDesc"
88+
done
7889
}
7990

8091
argUnexpected() {
@@ -205,5 +216,7 @@ argParse() {
205216

206217
# If we are accessing this script directly run the argument parser, useful for testing
207218
if [ "$0" == "$BASH_SOURCE" ]; then
219+
argExpected['t']="test - this is a test"
208220
argParse
221+
argList
209222
fi

0 commit comments

Comments
 (0)