Skip to content

warn when the cli is given an unknown option - #339

Open
avionicharshit-byte wants to merge 1 commit into
0xShug0:mainfrom
avionicharshit-byte:fix/warn-on-unused-cli-args
Open

warn when the cli is given an unknown option#339
avionicharshit-byte wants to merge 1 commit into
0xShug0:mainfrom
avionicharshit-byte:fix/warn-on-unused-cli-args

Conversation

@avionicharshit-byte

Copy link
Copy Markdown

fixes #338. a misspelled option is currently dropped without a word, so --bakend cuda runs on cpu and exits 0.

find_arg, has_arg and collect_args now record the name they were asked for, and report_unused_args names 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 a76ec04 on macos arm64, cmake -DAUDIOCPP_MODEL_SET=custom -DAUDIOCPP_MODELS=citrinet_asr --target audiocpp_cli:

command before after
--list-loaders silent, exit 0 silent, exit 0
--list-loaders --this-flag-does-not-exist silent, exit 0 ignored unknown option: --this-flag-does-not-exist, exit 0
--list-loaders --bakend cuda silent, exit 0 ignored unknown option: --bakend, exit 0
--task asr --family citrinet_asr --model <path> --sesion-option a=b silent ignored unknown option: --sesion-option
--list-loaders --log-file --weird-looking-value silent silent, the value is not an option
--list-loaders --foo --bar silent ignored unknown options: --foo --bar
--task asr --family citrinet_asr --model <path> --backend cpu --threads 2 silent silent

stdout 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audiocpp_cli silently ignores unknown options

1 participant