mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
fix(generate): Hide option/argument description for argenum
This returns `"{a\t,b\t}"` instead of `"a b"` for possible_values completion. Therefore fish displays and therefor hides the empty description after the `\t`. Fixes #2727
This commit is contained in:
parent
f085fa64f4
commit
174e004107
2 changed files with 10 additions and 2 deletions
|
@ -133,7 +133,15 @@ fn value_completion(option: &Arg) -> String {
|
|||
}
|
||||
|
||||
if let Some(data) = option.get_possible_values() {
|
||||
format!(" -r -f -a \"{}\"", data.join(" "))
|
||||
// We return the possible values with their own empty description e.g. {a\t,b\t}
|
||||
// this makes sure that a and b don't get the description of the option or argument
|
||||
format!(
|
||||
" -r -f -a \"{{{}}}\"",
|
||||
data.iter()
|
||||
.map(|value| format!("{}\t", value))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
)
|
||||
} else {
|
||||
// NB! If you change this, please also update the table in `ValueHint` documentation.
|
||||
match option.get_value_hint() {
|
||||
|
|
|
@ -131,7 +131,7 @@ _my_app_commands() {
|
|||
|
||||
_my_app "$@""#;
|
||||
|
||||
static FISH_VALUE_HINTS: &str = r#"complete -c my_app -l choice -r -f -a "bash fish zsh"
|
||||
static FISH_VALUE_HINTS: &str = r#"complete -c my_app -l choice -r -f -a "{bash ,fish ,zsh }"
|
||||
complete -c my_app -l unknown -r
|
||||
complete -c my_app -l other -r -f
|
||||
complete -c my_app -s p -l path -r -F
|
||||
|
|
Loading…
Reference in a new issue