Skip to content
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 gives runtime error, wouldn't it be cool, if it was compile time error #500

Closed
typetetris opened this issue Oct 5, 2021 · 2 comments
Labels
enhancement We would love to have this feature! Feel free to supply a PR

Comments

@typetetris
Copy link

Something like

use structopt::StructOpt;

#[derive(Debug,StructOpt)]
struct Opt {
      #[structopt(short, long)]
      fnord: u16,

      #[structopt(short, long)]
      file: String
}

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.

@TeXitoi
Copy link
Owner

TeXitoi commented Oct 5, 2021

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.

@TeXitoi
Copy link
Owner

TeXitoi commented Jan 18, 2022

This is an enhancement, and structopt is now feature frozen.

@TeXitoi TeXitoi closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement We would love to have this feature! Feel free to supply a PR
Projects
None yet
Development

No branches or pull requests

2 participants