mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
fix: detect if space should be added before spec_vals
This commit is contained in:
parent
29df5c2d16
commit
530b179776
3 changed files with 12 additions and 11 deletions
|
@ -504,7 +504,7 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
let env_info = format!(" [env: {}{}]", env.0.to_string_lossy(), env_val);
|
let env_info = format!("[env: {}{}]", env.0.to_string_lossy(), env_val);
|
||||||
spec_vals.push(env_info);
|
spec_vals.push(env_info);
|
||||||
}
|
}
|
||||||
if !a.is_set(ArgSettings::HideDefaultValue) && !a.default_vals.is_empty() {
|
if !a.is_set(ArgSettings::HideDefaultValue) && !a.default_vals.is_empty() {
|
||||||
|
@ -520,7 +520,7 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
spec_vals.push(format!(" [default: {}]", pvs));
|
spec_vals.push(format!("[default: {}]", pvs));
|
||||||
}
|
}
|
||||||
if !a.aliases.is_empty() {
|
if !a.aliases.is_empty() {
|
||||||
debug!("Help::spec_vals: Found aliases...{:?}", a.aliases);
|
debug!("Help::spec_vals: Found aliases...{:?}", a.aliases);
|
||||||
|
@ -534,7 +534,7 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
|
||||||
if !als.is_empty() {
|
if !als.is_empty() {
|
||||||
spec_vals.push(format!(" [aliases: {}]", als));
|
spec_vals.push(format!("[aliases: {}]", als));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,12 +566,13 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
|
||||||
a.possible_vals
|
a.possible_vals
|
||||||
);
|
);
|
||||||
|
|
||||||
spec_vals.push(format!(
|
spec_vals.push(format!("[possible values: {}]", a.possible_vals.join(", ")));
|
||||||
" [possible values: {}]",
|
|
||||||
a.possible_vals.join(", ")
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
spec_vals.join(" ")
|
let prefix = match !spec_vals.is_empty() && !a.get_about().unwrap_or("").is_empty() {
|
||||||
|
true => " ",
|
||||||
|
false => "",
|
||||||
|
};
|
||||||
|
prefix.to_string() + &spec_vals.join(" ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@ USAGE:
|
||||||
ct test [FLAGS] [OPTIONS]
|
ct test [FLAGS] [OPTIONS]
|
||||||
|
|
||||||
FLAGS:
|
FLAGS:
|
||||||
-f, --flag [aliases: v_flg, flag2, flg3]
|
-f, --flag [aliases: v_flg, flag2, flg3]
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-V, --version Prints version information
|
-V, --version Prints version information
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-o, --opt <opt> [aliases: visible]";
|
-o, --opt <opt> [aliases: visible]";
|
||||||
|
|
||||||
static SC_INVISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
static SC_INVISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||||
Some help
|
Some help
|
||||||
|
|
|
@ -9,7 +9,7 @@ USAGE:
|
||||||
ct test [FLAGS] [OPTIONS]
|
ct test [FLAGS] [OPTIONS]
|
||||||
|
|
||||||
FLAGS:
|
FLAGS:
|
||||||
-f, --flag [aliases: flag1] [short aliases: a, b, 🦆]
|
-f, --flag [aliases: flag1] [short aliases: a, b, 🦆]
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-V, --version Prints version information
|
-V, --version Prints version information
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue