Conversation
mhshami01
commented
May 17, 2021
- modified the add_arg function to take multiple arguments.
- enabled boolean type options.
- added a 'reset' for argument parser.
- update parser's unit tests
| # compare output, should be empty | ||
| if [ "${parsed_cmds[*]}" != "" ]; | ||
| then | ||
| echo "Failed to pass unit test 'test_illegal_flags' in test-cmd-parser.sh. Non-empty result: ${parsed_cmds[*]}" |
There was a problem hiding this comment.
is this a good place to use the loggers for our unit test outputs?
There was a problem hiding this comment.
I don't know. Let's discuss this point during planning...
| done | ||
|
|
||
| for arg in "$@" | ||
| while [ $# -ne 0 ]; |
There was a problem hiding this comment.
for my own learning, is it better to use a while instead of a for loop in these kind of situations?
There was a problem hiding this comment.
1- Since I need to look at $1 and $2, the $arg and $2 seemed inconsistent.
2- I personally find this form simpler and less error prone.
| if [[ "$valid_arg" == "false" ]]; | ||
| if [[ "$valid_argument" == "false" ]]; | ||
| then | ||
| parsed_cmd=() |
There was a problem hiding this comment.
Let user know when the arguments are invalid?
There was a problem hiding this comment.
I would like to leave this for a later iteration. I think it is a large enough scope to require its own PBI.