Deprecate Arg::help in favour of Arg::about

This commit is contained in:
creativcoder 2020-04-19 17:00:39 +05:30 committed by creativcoder
parent 1e800ed2b9
commit 24cb8b13c5
9 changed files with 113 additions and 100 deletions

View file

@ -79,14 +79,14 @@ fn generate_inner<'b>(
for option in opts!(p) {
if let Some(data) = option.get_short() {
let tooltip = get_tooltip(option.get_help(), data);
let tooltip = get_tooltip(option.get_about(), data);
completions.push_str(&preamble);
completions.push_str(format!("-{} '{}'", data, tooltip).as_str());
}
if let Some(data) = option.get_long() {
let tooltip = get_tooltip(option.get_help(), data);
let tooltip = get_tooltip(option.get_about(), data);
completions.push_str(&preamble);
completions.push_str(format!("--{} '{}'", data, tooltip).as_str());
@ -95,14 +95,14 @@ fn generate_inner<'b>(
for flag in Elvish::flags(p) {
if let Some(data) = flag.get_short() {
let tooltip = get_tooltip(flag.get_help(), data);
let tooltip = get_tooltip(flag.get_about(), data);
completions.push_str(&preamble);
completions.push_str(format!("-{} '{}'", data, tooltip).as_str());
}
if let Some(data) = flag.get_long() {
let tooltip = get_tooltip(flag.get_help(), data);
let tooltip = get_tooltip(flag.get_about(), data);
completions.push_str(&preamble);
completions.push_str(format!("--{} '{}'", data, tooltip).as_str());

View file

@ -65,7 +65,7 @@ fn gen_fish_inner(root_command: &str, app: &App, buffer: &mut String) {
template.push_str(format!(" -l {}", data).as_str());
}
if let Some(data) = option.get_help() {
if let Some(data) = option.get_about() {
template.push_str(format!(" -d '{}'", escape_string(data)).as_str());
}
@ -88,7 +88,7 @@ fn gen_fish_inner(root_command: &str, app: &App, buffer: &mut String) {
template.push_str(format!(" -l {}", data).as_str());
}
if let Some(data) = flag.get_help() {
if let Some(data) = flag.get_about() {
template.push_str(format!(" -d '{}'", escape_string(data)).as_str());
}

View file

@ -86,7 +86,7 @@ fn generate_inner<'b>(
for option in opts!(p) {
if let Some(data) = option.get_short() {
let tooltip = get_tooltip(option.get_help(), data);
let tooltip = get_tooltip(option.get_about(), data);
completions.push_str(&preamble);
completions.push_str(
@ -99,7 +99,7 @@ fn generate_inner<'b>(
}
if let Some(data) = option.get_long() {
let tooltip = get_tooltip(option.get_help(), data);
let tooltip = get_tooltip(option.get_about(), data);
completions.push_str(&preamble);
completions.push_str(
@ -114,7 +114,7 @@ fn generate_inner<'b>(
for flag in PowerShell::flags(p) {
if let Some(data) = flag.get_short() {
let tooltip = get_tooltip(flag.get_help(), data);
let tooltip = get_tooltip(flag.get_about(), data);
completions.push_str(&preamble);
completions.push_str(
@ -127,7 +127,7 @@ fn generate_inner<'b>(
}
if let Some(data) = flag.get_long() {
let tooltip = get_tooltip(flag.get_help(), data);
let tooltip = get_tooltip(flag.get_about(), data);
completions.push_str(&preamble);
completions.push_str(

View file

@ -357,7 +357,7 @@ fn write_opts_of(p: &App) -> String {
for o in opts!(p) {
debug!("write_opts_of:iter: o={}", o.get_name());
let help = o.get_help().map_or(String::new(), escape_help);
let help = o.get_about().map_or(String::new(), escape_help);
let conflicts = arg_conflicts(p, o);
// @TODO @soundness should probably be either multiple occurrences or multiple values and
@ -444,7 +444,7 @@ fn write_flags_of(p: &App) -> String {
for f in Zsh::flags(p) {
debug!("write_flags_of:iter: f={}", f.get_name());
let help = f.get_help().map_or(String::new(), escape_help);
let help = f.get_about().map_or(String::new(), escape_help);
let conflicts = arg_conflicts(p, &f);
let multiple = if f.is_set(ArgSettings::MultipleOccurrences) {
@ -504,7 +504,7 @@ fn write_positionals_of(p: &App) -> String {
optional = optional,
name = arg.get_name(),
help = arg
.get_help()
.get_about()
.map_or("".to_owned(), |v| " -- ".to_owned() + v)
.replace("[", "\\[")
.replace("]", "\\]")

View file

@ -1562,7 +1562,7 @@ impl<'b> App<'b> {
.args
.args
.iter()
.filter(|arg| arg.help.is_none() && arg.long_help.is_none())
.filter(|arg| arg.about.is_none() && arg.long_help.is_none())
.map(|arg| String::from(arg.name))
.collect();

View file

@ -51,7 +51,12 @@ type ValidatorOs = Rc<dyn Fn(&OsStr) -> Result<(), String>>;
pub struct Arg<'help> {
pub(crate) id: Id,
pub(crate) name: &'help str,
#[deprecated(
since = "3.0.0",
note = "Please use `about` field instead"
)]
pub(crate) help: Option<&'help str>,
pub(crate) about: Option<&'help str>,
pub(crate) long_help: Option<&'help str>,
pub(crate) blacklist: Option<Vec<Id>>,
pub(crate) settings: ArgFlags,
@ -92,9 +97,17 @@ impl<'help> Arg<'help> {
}
/// Get the help specified for this argument, if any
#[inline]
#[deprecated(
since = "3.0.0",
note = "Please use `get_about` method instead"
)]
pub fn get_help(&self) -> Option<&str> {
self.help
self.about
}
/// Get the help specified for this argument, if any
pub fn get_about(&self) -> Option<&str> {
self.about
}
/// Get the help heading specified for this argument, if any
@ -500,7 +513,7 @@ impl<'help> Arg<'help> {
/// [`Arg::long_help`]: ./struct.Arg.html#method.long_help
#[inline]
pub fn help(mut self, h: &'help str) -> Self {
self.help = Some(h);
self.about = Some(h);
self
}
@ -4353,7 +4366,7 @@ impl<'help> fmt::Debug for Arg<'help> {
}}",
self.id,
self.name,
self.help,
self.about,
self.long_help,
self.blacklist,
self.settings,

View file

@ -6,7 +6,7 @@ fn short_flag_misspel() {
assert_eq!(a.name, "flag");
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.help.unwrap(), "some flag");
assert_eq!(a.about.unwrap(), "some flag");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -18,7 +18,7 @@ fn short_flag_name_missing() {
assert_eq!(a.name, "f");
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some flag");
assert_eq!(a.about.unwrap(), "some flag");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());

View file

@ -202,7 +202,7 @@ impl<'a> UsageParser<'a> {
"UsageParser::help: setting help...{}",
&self.usage[self.start..self.pos]
);
arg.help = Some(&self.usage[self.start..self.pos]);
arg.about = Some(&self.usage[self.start..self.pos]);
self.pos += 1; // Move to next byte to keep from thinking ending ' is a start
self.prev = UsageToken::Help;
}
@ -262,7 +262,7 @@ mod test {
assert_eq!(a.name, "flag");
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -271,7 +271,7 @@ mod test {
assert_eq!(a.name, "flag");
assert_eq!(a.long.unwrap(), "flag");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -280,7 +280,7 @@ mod test {
assert_eq!(a.name, "flag");
assert_eq!(a.long.unwrap(), "flag");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -289,7 +289,7 @@ mod test {
assert_eq!(a.name, "flag");
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -298,7 +298,7 @@ mod test {
assert_eq!(a.name, "flag");
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -307,7 +307,7 @@ mod test {
assert_eq!(a.name, "flag");
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -316,7 +316,7 @@ mod test {
assert_eq!(a.name, "flag");
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -351,7 +351,7 @@ mod test {
assert_eq!(a.name, "f");
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_none());
assert!(a.num_vals.is_none());
@ -377,7 +377,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -392,7 +392,7 @@ mod test {
assert_eq!(a.name, "o");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -407,7 +407,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -422,7 +422,7 @@ mod test {
assert_eq!(a.name, "o");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -437,7 +437,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -452,7 +452,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
@ -466,7 +466,7 @@ mod test {
assert_eq!(a.name, "o");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -481,7 +481,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -496,7 +496,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
@ -510,7 +510,7 @@ mod test {
assert_eq!(a.name, "o");
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -525,7 +525,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -540,7 +540,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -558,7 +558,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -573,7 +573,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -591,7 +591,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -606,7 +606,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
@ -620,7 +620,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -638,7 +638,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
@ -653,7 +653,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
@ -667,7 +667,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -686,7 +686,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -702,7 +702,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -721,7 +721,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -737,7 +737,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -756,7 +756,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -772,7 +772,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
@ -786,7 +786,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -805,7 +805,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -821,7 +821,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
@ -835,7 +835,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -854,7 +854,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -873,7 +873,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -892,7 +892,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -908,7 +908,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -927,7 +927,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
@ -944,7 +944,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -963,7 +963,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
@ -977,7 +977,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -996,7 +996,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1015,7 +1015,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1034,7 +1034,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1050,7 +1050,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1069,7 +1069,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
@ -1086,7 +1086,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1105,7 +1105,7 @@ mod test {
assert_eq!(a.name, "option");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
@ -1119,7 +1119,7 @@ mod test {
assert_eq!(a.name, "opt");
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1138,7 +1138,7 @@ mod test {
assert_eq!(a.name, "o");
assert!(a.long.is_none());
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1157,7 +1157,7 @@ mod test {
assert_eq!(a.name, "o");
assert!(a.long.is_none());
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1176,7 +1176,7 @@ mod test {
assert_eq!(a.name, "opt");
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1195,7 +1195,7 @@ mod test {
assert_eq!(a.name, "myopt");
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1214,7 +1214,7 @@ mod test {
assert_eq!(a.name, "opt");
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1227,7 +1227,7 @@ mod test {
fn create_positional_usage() {
let a = Arg::from("[pos] 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1240,7 +1240,7 @@ mod test {
fn create_positional_usage0() {
let a = Arg::from("<pos> 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1253,7 +1253,7 @@ mod test {
fn pos_mult_help() {
let a = Arg::from("[pos]... 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1266,7 +1266,7 @@ mod test {
fn pos_help_lit_single_quote() {
let a = Arg::from("[pos]... 'some help\' info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help' info");
assert_eq!(a.about.unwrap(), "some help' info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1279,7 +1279,7 @@ mod test {
fn pos_help_double_lit_single_quote() {
let a = Arg::from("[pos]... 'some \'help\' info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some 'help' info");
assert_eq!(a.about.unwrap(), "some 'help' info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1295,7 +1295,7 @@ mod test {
info'",
);
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help\ninfo");
assert_eq!(a.about.unwrap(), "some help\ninfo");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1311,7 +1311,7 @@ mod test {
info'",
);
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help' stuff\ninfo");
assert_eq!(a.about.unwrap(), "some help' stuff\ninfo");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1324,7 +1324,7 @@ mod test {
fn pos_req_mult_help() {
let a = Arg::from("<pos>... 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1361,7 +1361,7 @@ mod test {
fn pos_req_mult_def_help() {
let a = Arg::from("<pos>... @a 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
);
@ -1377,7 +1377,7 @@ mod test {
assert_eq!(a.name, "o");
assert!(a.long.is_none());
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1397,7 +1397,7 @@ mod test {
assert_eq!(a.name, "myopt");
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert_eq!(a.about.unwrap(), "some help info");
assert!(
!(a.is_set(ArgSettings::MultipleValues) || a.is_set(ArgSettings::MultipleOccurrences))
);
@ -1415,21 +1415,21 @@ mod test {
fn nonascii() {
let a = Arg::from("<ASCII> 'üñíčöĐ€'");
assert_eq!(a.name, "ASCII");
assert_eq!(a.help, Some("üñíčöĐ€"));
assert_eq!(a.about, Some("üñíčöĐ€"));
let a = Arg::from("<üñíčöĐ€> 'ASCII'");
assert_eq!(a.name, "üñíčöĐ€");
assert_eq!(a.help, Some("ASCII"));
assert_eq!(a.about, Some("ASCII"));
let a = Arg::from("<üñíčöĐ€> 'üñíčöĐ€'");
assert_eq!(a.name, "üñíčöĐ€");
assert_eq!(a.help, Some("üñíčöĐ€"));
assert_eq!(a.about, Some("üñíčöĐ€"));
let a = Arg::from("-ø 'ø'");
assert_eq!(a.name, "ø");
assert_eq!(a.short, Some('ø'));
assert_eq!(a.help, Some("ø"));
assert_eq!(a.about, Some("ø"));
let a = Arg::from("--üñíčöĐ€ 'Nōṫ ASCII'");
assert_eq!(a.name, "üñíčöĐ€");
assert_eq!(a.long, Some("üñíčöĐ€"));
assert_eq!(a.help, Some("Nōṫ ASCII"));
assert_eq!(a.about, Some("Nōṫ ASCII"));
let a = Arg::from("[ñämê] --ôpt=[üñíčöĐ€] 'hælp'");
assert_eq!(a.name, "ñämê");
assert_eq!(a.long, Some("ôpt"));
@ -1437,6 +1437,6 @@ mod test {
a.val_names.unwrap().values().collect::<Vec<_>>(),
[&"üñíčöĐ€"]
);
assert_eq!(a.help, Some("hælp"));
assert_eq!(a.about, Some("hælp"));
}
}

View file

@ -312,7 +312,7 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
}
let spec_vals = self.spec_vals(arg);
let h = arg.help.unwrap_or("");
let h = arg.about.unwrap_or("");
let h_w = str_width(h) + str_width(&*spec_vals);
let nlh = self.next_line_help || arg.is_set(ArgSettings::NextLineHelp);
let taken = self.longest + 12;
@ -399,9 +399,9 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
fn help(&mut self, arg: &Arg<'c>, spec_vals: &str, prevent_nlh: bool) -> io::Result<()> {
debug!("Help::help");
let h = if self.use_long {
arg.long_help.unwrap_or_else(|| arg.help.unwrap_or(""))
arg.long_help.unwrap_or_else(|| arg.about.unwrap_or(""))
} else {
arg.help.unwrap_or_else(|| arg.long_help.unwrap_or(""))
arg.about.unwrap_or_else(|| arg.long_help.unwrap_or(""))
};
let mut help = String::from(h) + spec_vals;
let nlh = self.next_line_help || arg.is_set(ArgSettings::NextLineHelp) || self.use_long;