warn when the cli is given an unknown option - #339
Open
avionicharshit-byte wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #338. a misspelled option is currently dropped without a word, so
--bakend cudaruns on cpu and exits 0.find_arg,has_argandcollect_argsnow record the name they were asked for, andreport_unused_argsnames anything on the command line that nobody asked about. there is no second list of flags to keep in sync, a new option is recognised the moment its lookup is added.value-taking and boolean lookups are recorded separately because only the first kind consumes the next argument. without that split a typo sitting after a boolean flag gets swallowed as its value, and a value that happens to start with
--gets reported as an option. both were real, both are covered below.it warns, it does not fail. the message goes to stderr, exit codes and stdout are untouched, so nothing that parses output or passes a stray flag today breaks. a hard error is a two line change if you would rather have it, which is the open question on the issue.
built at
a76ec04on macos arm64,cmake -DAUDIOCPP_MODEL_SET=custom -DAUDIOCPP_MODELS=citrinet_asr --target audiocpp_cli:--list-loaders--list-loaders --this-flag-does-not-existignored unknown option: --this-flag-does-not-exist, exit 0--list-loaders --bakend cudaignored unknown option: --bakend, exit 0--task asr --family citrinet_asr --model <path> --sesion-option a=bignored unknown option: --sesion-option--list-loaders --log-file --weird-looking-value--list-loaders --foo --barignored unknown options: --foo --bar--task asr --family citrinet_asr --model <path> --backend cpu --threads 2stdout is byte for byte unchanged in all of the above, the warning is stderr only.
what this does not do: it reports after the run rather than refusing before it, so a long job still runs to completion before you are told. checking earlier would mean the lookups that happen inside model code have not run yet, which would report real options as unknown. happy to move it if you would rather have the check up front and are willing to declare the flag set somewhere central.