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

Raw ident for struct member prefixes "r-" to parameter and value names #269

Closed
Arnavion opened this issue Oct 4, 2019 · 3 comments · Fixed by #278
Closed

Raw ident for struct member prefixes "r-" to parameter and value names #269

Arnavion opened this issue Oct 4, 2019 · 3 comments · Fixed by #278
Labels
enhancement We would love to have this feature! Feel free to supply a PR

Comments

@Arnavion
Copy link

Arnavion commented Oct 4, 2019

  • structopt v0.3.2
  • structopt-derive v0.3.2
#[derive(structopt::StructOpt)]
struct Options {
    #[structopt(long)]
    r#type: String,
}

fn main() {
    let _: Options = structopt::StructOpt::from_args();
}
$ cargo run -- --help

rust-test 0.1.0

USAGE:
    rust-test --r-type <r-type>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --r-type <r-type>

The parameter long name --r-type should be --type, and the parameter value string r-type should be type. Basically the r# of the struct member ident should not contribute to the clap::Arg parameters.

(Can be worked around by setting #[structopt(long = "type", name = "type")] explicitly.)

@TeXitoi TeXitoi added the enhancement We would love to have this feature! Feel free to supply a PR label Oct 4, 2019
@CreepySkeleton
Copy link
Collaborator

@TeXitoi This is more of a bug than enhancement

@TeXitoi
Copy link
Owner

TeXitoi commented Oct 9, 2019

I put it as enhancement as this case was not documented, and the result, even if surprising, is not problematic. I agree that we can correct this without changing version.

@Arnavion
Copy link
Author

Arnavion commented Oct 9, 2019

Technically it would be a breaking change for anyone who was relying on the behavior, eg their scripts (and the scripts of their binary's users) that used --r-type would stop working. Though of course that's probably not very likely.

This was referenced Nov 3, 2019
TeXitoi pushed a commit that referenced this issue Nov 8, 2019
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

Successfully merging a pull request may close this issue.

3 participants