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

no_version have to be marked twice to hide version info of subcommand #3132

Closed
epage opened this issue Dec 9, 2021 · 2 comments
Closed

no_version have to be marked twice to hide version info of subcommand #3132

epage opened this issue Dec 9, 2021 · 2 comments
Labels
A-derive Area: #[derive]` macro API

Comments

@epage
Copy link
Member

epage commented Dec 9, 2021

Issue by loichyan
Friday Feb 12, 2021 at 10:36 GMT
Originally opened as TeXitoi/structopt#465


In code below, I have to mark no_version at both P1 and P2 to hide version info of sub1. For subcommands, their version info should be successfully hided when I marked no_version anywhere.

use structopt::clap::AppSettings::DisableVersion;

#[derive(structopt::StructOpt)]
enum Cmd {
    #[structopt(no_version)]  // P1
    Sub1(Sub1),
}

#[derive(structopt::StructOpt)]
#[structopt(
    no_version,  // P2
    global_settings = &[DisableVersion])]
struct Sub1 {}

#[paw::main]
fn main(cmd: Cmd) {
    match cmd {
        Cmd::Sub1(_s1) => {}
    }
}

BTW, this sounds a little similar to #324.

@epage
Copy link
Member Author

epage commented Dec 9, 2021

Comment by TeXitoi
Friday Mar 05, 2021 at 13:33 GMT


There is no way of removing the version of a subcommand, as the different enum can't know each others.

The real solution to this problem would be to have no default version handling, and a argument less version to find automatically the version number. It would be coherent with authors. But that's a breaking change, and that's not enough to justify a new major version.

@epage
Copy link
Member Author

epage commented Dec 9, 2021

version is now opt-in, instead of opt-out. We also only propagate populated versions. I believe this is now fixed.

@epage epage closed this as completed Dec 9, 2021
@epage epage added the A-derive Area: #[derive]` macro API label Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: #[derive]` macro API
Projects
None yet
Development

No branches or pull requests

1 participant