-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CLI] Report errors for command line options that have no effect #11629
Comments
Hi @cameel I would like to work on this issue. |
Great! There are many options so maybe it would be best to start with a PR that does this for only one of them and then, when you get the hang of it, continue with the rest in subsequent PRs. I think that Start by running After you do this, tests in Finally, don't forget to mention your change in the changelog. If you need more help, drop by at the |
Thank you for the detailed explanation, It is really helpful. I will start with the said option. |
#11853 looks good overall. Here are some pointers on where to go from there once we merge it:
|
@cameel Thank you for merging the PR. I shall start with the other options. A couple of questions, Can I use the test case that I made in the previous PR for the rest of the options, maybe loop over each invalid option-input mode combination. Also, can I fix multiple option cases in a single PR. |
Sure. I wanted a PR dealing with a single one mostly to work through potential issues on something small. Now I think we could do something bigger. But I think it would be best to submit an incomplete PR as a draft for some feedback and add more stuff to it once we agree on the overall structure.
Yeah, that's exactly what we need. That test should be refactored into something more generic. There are a lot of options and they should all be handled in a uniform way anyway so looping over them will save us a lot of code. |
@cameel What should be the action if the user enters multiple invalid options for an input mode? Should it exit and return an error on the First invalid option or return errors for all invalid options? Please clarify. |
I think it should report one error listing the names of all the invalid options and then exit. |
@cameel So I assume when creating test cases we need to check for |
I think that checking all of the |
@cameel I have created fix for option |
#11350 will soon be merged. When that happens, we need to remember to also validate its options (currently it does not take any so they all should be rejected as invalid). |
Hi everyone! This issue has been closed due to inactivity. |
Abstract
The compiler is pretty lax about command-line options whose values it does not use and just ignores many of them. It should report errors instead.
Over time we've started adding checks against this (e.g. #9075, #9364) they they're still very incomplete.
Motivation
Not getting an error when an option is invalid makes it harder for the user to realize that. It's especially problematic with options that seem to make sense together:
--pretty-json
sounds like it would affect--standard-json
but it only works with--combined-json
(Make--pretty-json
work with Standard JSON output #11583.)--bin
should be supported in the assembler mode but currently isn't ([CLI] Do not ignore the output selection in assembler mode #3870).Specification
CommandLineParser
. Basically, all options do not result in a change inCommandLineOptions
in a specific mode should be invalid in that mode.--standard-json
is used. For example:--color
/--no-color
- Standard JSON output is not colorized and even when it will be (Support coloured messages in standard json #11507), this option should not affect it.--libraries
.--error-codes
.CommandLineParser
but are still not used byCommandLineInterface
.Backwards Compatibility
This does not introduce any backwards-incompatible changes to the language itself but any command-line tools relying on the current behavior of options being ignored will be affected.
The text was updated successfully, but these errors were encountered: