Skip to content

Commit

Permalink
show help in case of unknown arg
Browse files Browse the repository at this point in the history
  • Loading branch information
robstoll committed Mar 13, 2024
1 parent f94f925 commit b7cbea4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utility/parse-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,14 @@ function parseArgumentsInternal {
done

if [[ $parseArguments_unknownBehaviour = 'error' ]] && ((parseArguments_expectedName == 0)); then
parse_args_printHelp >&2 parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version"
if [[ $parseArguments_argName =~ ^- ]] && (($# > 1)); then
die "unknown argument \033[1;36m%s\033[0m (and value %s)" "$parseArguments_argName" "$2"
logError "unknown argument \033[1;36m%s\033[0m (and value %s)" "$parseArguments_argName" "$2"
else
die "unknown argument \033[1;36m%s\033[0m" "$parseArguments_argName"
logError "unknown argument \033[1;36m%s\033[0m" "$parseArguments_argName"
fi
echo >&2 "consult the output of --help shown further above for valid names"
exit 9
fi
shift || die "could not shift by 1"
done
Expand Down

0 comments on commit b7cbea4

Please sign in to comment.