-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Duplicate short option (and other misconfigurations) gives runtime error, wouldn't it be cool, if it was compile time error #3133
Comments
Comment by TeXitoi I doubt this particular example will panic. Edit: ho, OK, short argument, yep, it'll panic. There is no easy way of checking you use the same name several times. Basic case is double, bit when you add flatten and friends, it can become a nightmare. I don't want complicated code to do compile time check that would be catch in all case with a basic test. Now, if the code is really trivial, why not, but I doubt. |
This is panic during development runtime now. But looks the issue is talking about compile time. |
Yes. As TeXitoi says, we can do this in the trivial case though it won't scale to complex caes ( For the trivial case, the main complication is how we currently have the code structured. We take the raw attributes and convert them straight to Our options for implementing this:
|
Note: we have #2740 which is about supporting all of the debug assets at compile time. |
A workaround seems to be to use |
Could you expand on how We do recommend creating tests out of the runtime checks which will catch it during development and will check every subcommand possible, rather than what was run by the user. See https://github.com/clap-rs/clap/blob/v3.1.6/examples/tutorial_builder/README.md#tips |
Ah, sorry, I was unclear. What I meant is that I used |
Yes, I understand that but that increases our maintenance burden because we have to support and test the checks at both compile time and runtime. We also would need to detect and limit what checks we run when the user |
Makes sense. I understand the issue with |
Issue by typetetris
Tuesday Oct 05, 2021 at 13:32 GMT
Originally opened as TeXitoi/structopt#500
Something like
gives an error at runtime of the program.
It would be way cooler, if it was a compile time error.
If you agree, I could look into trying to implement this.
The text was updated successfully, but these errors were encountered: