Skip to content

Commit

Permalink
feat(Args): allows opts and args to define a name for help and usage …
Browse files Browse the repository at this point in the history
…msgs
  • Loading branch information
kbknapp committed Aug 27, 2015
1 parent 4b8908b commit ad962ec
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/args/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,29 @@ impl<'n, 'l, 'h, 'g, 'p, 'r> Arg<'n, 'l, 'h, 'g, 'p, 'r> {
}
self
}

/// Specifies the name for value of option or positional arguments. This name is cosmetic only,
/// used for help and usage strings. The name is **not** used to access arguments.
///
/// # Example
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let matches = App::new("myprog")
/// # .arg(
/// Arg::with_name("debug")
/// .index(1)
/// .value_name("file")
/// # ).get_matches();
pub fn value_name(mut self, name: &'n str)
-> Self {
if let Some(ref mut vec) = self.val_names {
vec.push(name);
} else {
self.val_names = Some(vec![name]);
}
self
}
}

impl<'n, 'l, 'h, 'g, 'p, 'r, 'z> From<&'z Arg<'n, 'l, 'h, 'g, 'p, 'r>> for Arg<'n, 'l, 'h, 'g, 'p, 'r> {
Expand Down

0 comments on commit ad962ec

Please sign in to comment.