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

Cannot use custom --version with DisableVersion #922

Closed
anna-is-cute opened this issue Apr 4, 2017 · 3 comments
Closed

Cannot use custom --version with DisableVersion #922

anna-is-cute opened this issue Apr 4, 2017 · 3 comments
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies

Comments

@anna-is-cute
Copy link

Rust Version

rustc 1.18.0-nightly (5e122f59b 2017-04-01)

Affected Version of clap

clap 2.22.2

Expected Behavior Summary

Overriding --version should allow use of a custom version flag.

Actual Behavior Summary

The default version provided by clap is used.

Steps to Reproduce the issue

Specify an Arg with short("v") and long("version").

Sample Code or Link to Sample Code

extern crate clap;

use clap::{App, Arg, AppSettings};

fn main() {
  let matches = App::new("clap-bug")
    .setting(AppSettings::DisableVersion)
    .arg(Arg::with_name("version")
      .short("v")
      .long("version")
      .help("custom version"))
    .get_matches();

  println!("{}", matches.is_present("version"));
}

Debug output

Output

@anna-is-cute anna-is-cute changed the title Cannot use custom --version (but can use custom -v) Cannot use custom --version with DisableVersion Apr 4, 2017
@kbknapp
Copy link
Member

kbknapp commented Apr 4, 2017

Thanks for taking the time to file this! I do have a question however; why are you using DisableVersion? You can override the default --version by only supplying an arg with a long of version.

As I understand it, and please correct me if I'm wrong, this would be an area where I could improve the docs.

@anna-is-cute
Copy link
Author

From what I understood, you needed to use DisableVersion to override the default --version, but now I know that it's not necessary! I agree that a note in the docs would be helpful to clear any misunderstandings.

I can still reproduce the issue when not using DisableVersion, though.

@kbknapp
Copy link
Member

kbknapp commented Apr 4, 2017

Ah ok, then that is a bug!

@kbknapp kbknapp added A-parsing Area: Parser's logic and needs it changed somehow. D: easy C-bug Category: Updating dependencies and removed T: RFC / question labels Apr 4, 2017
@homu homu closed this as completed in 8b2ceb8 Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants