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

Argument requiring equals does not print = in help #903

Closed
TimBednarzyk opened this issue Mar 14, 2017 · 1 comment
Closed

Argument requiring equals does not print = in help #903

TimBednarzyk opened this issue Mar 14, 2017 · 1 comment
Labels
C-enhancement Category: Raise on the bar on expectations E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@TimBednarzyk
Copy link

Rust Version

1.14.0

Affected Version of clap

2.21.1

Expected Behavior Summary

When calling arg.require_equals(true), the generated help message should show --arg=<VALUE>. Without the equals sign in the help message, the user will think to put a space and will be confused when that fails.

Actual Behavior Summary

The help message shows --arg <VALUE>

Sample Code

extern crate clap;

use clap::*;

fn main() {
  let matches = App::new("example")
    .arg(Arg::with_name("mode")
         .long("mode")
         .value_name("MODE")
         .require_equals(true)
         .default_value("foo")
         .possible_values(&["foo", "bar"])
         ).get_matches();

  if matches.value_of("mode").unwrap() == "foo" {
    println!("mode == foo");
  }
  else {
    println!("mode == bar");
  }
}

Debug output

image

@kbknapp
Copy link
Member

kbknapp commented Mar 15, 2017

Great point, I hadn't thought about that. This is a very simple fix. I'm away from my computer for a few days, but will knock this out first thing when I return. If anyone submits a PR, it's simply adding some lines to the Display implementation of OptBuilder.

@kbknapp kbknapp added C: options E-medium Call for participation: Experience needed to fix: Medium / intermediate C-enhancement Category: Raise on the bar on expectations labels Mar 15, 2017
@homu homu closed this as completed in c8eb038 Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

No branches or pull requests

2 participants