fix(complete): Have shorts fallback to using long as description

It should be rare that this is helpful
This commit is contained in:
Ed Page 2024-09-20 13:39:41 -05:00
parent 8af051c439
commit cd6280fc87
2 changed files with 7 additions and 3 deletions

View file

@ -447,7 +447,11 @@ fn shorts_and_visible_aliases(p: &clap::Command) -> Vec<CompletionCandidate> {
a.get_short_and_visible_aliases().map(|shorts| {
shorts.into_iter().map(|s| {
CompletionCandidate::new(s.to_string())
.help(a.get_help().cloned())
.help(
a.get_help()
.cloned()
.or_else(|| a.get_long().map(|long| format!("--{long}").into())),
)
.id(Some(format!("arg::{}", a.get_id())))
.hide(a.is_hide_set())
})

View file

@ -1114,8 +1114,8 @@ pos-c
assert_data_eq!(
complete!(cmd, "-[TAB]"),
snapbox::str![[r#"
-r
-o
-r --required-flag
-o --optional-flag
-s
-h Print help
--long-flag