Skip to content

Commit

Permalink
Merge pull request #141 from tegonal/feature/warn-if-command-after-help
Browse files Browse the repository at this point in the history
warn if arguments are supplied after --help
  • Loading branch information
robstoll authored Aug 18, 2023
2 parents 7926ab2 + e405f1a commit 9e94776
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utility/parse-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ function parseArguments {
while (($# > 0)); do
parseArguments_argName="$1"
if [[ $parseArguments_argName == --help ]]; then
parse_args_printHelp parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version"
if ! ((parseArguments_numOfArgumentsParsed == 0)); then
logWarning "there were arguments defined prior to --help, they will all be ignored and instead parse_args_printHelp will be called"
logWarning "there were arguments defined prior to --help, they were all ignored and instead the help is shown"
elif (($# > 1)); then
logWarning "there were arguments defined after --help, they were all be ignored, you might want to remove --help"
fi
parse_args_printHelp parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version"
return 99
fi
if [[ $parseArguments_argName == --version ]]; then
Expand Down

0 comments on commit 9e94776

Please sign in to comment.