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

Inherit no_version for enum variants #242

Closed
dtolnay opened this issue Aug 30, 2019 · 6 comments · Fixed by #313
Closed

Inherit no_version for enum variants #242

dtolnay opened this issue Aug 30, 2019 · 6 comments · Fixed by #313
Labels
enhancement We would love to have this feature! Feel free to supply a PR

Comments

@dtolnay
Copy link

dtolnay commented Aug 30, 2019

In my non-Cargo build environment I end up with a lot of noise from no_version attributes. For subcommands, if the outer enum is no_version I think I shouldn't need to specify no_version as well for each of the command variants.

Currently derive(StructOpt) produces an error if any of the no_version attrs here are removed:

use structopt::StructOpt;

#[derive(StructOpt)]
#[structopt(no_version)]
enum Show {
    #[structopt(no_version)]
    Stats,
    #[structopt(no_version)]
    Capacity,
}
@CreepySkeleton
Copy link
Collaborator

I agree. @TeXitoi what do you think?

By the way, @dtolnay , I wonder what non-cargo environment you're working with?

@CreepySkeleton
Copy link
Collaborator

By the way, it looks like a bug - #[structopt(no_verison)] should not (and need not to) be usable on enum variants, only on top of the struct or enum

@TeXitoi
Copy link
Owner

TeXitoi commented Aug 31, 2019

That's because the enum can be transformed to a clap::App, and that each enum is a subcommand that also generate a clap::App.

@CreepySkeleton
Copy link
Collaborator

I'll see if we can catch this situation. I also think that no_version should be propagated down to subcommands - if we don't want version for the program itself why would we wan a version for subcommands?

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

@TeXitoi so what do you think about it? It can be implemented almost for no effort.

@TeXitoi
Copy link
Owner

TeXitoi commented Dec 6, 2019

Then OK for it

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