mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 07:12:32 +00:00
36bc641648
This is an intermediate solution for #4408. As there were no agreeed upon goals, I went with what I felt read well and that I saw commonly used on non-clap commands. - "information" isn't really a necessary word. - I originally favored `Print this help` but realied that doesn't read correctly in completions. - Besides being shorter, the reason for the flipped short/long hint is it gives people the context they need for scanning, emphasizing "summary" and "more". Fixes #4409
46 lines
1.2 KiB
Text
46 lines
1.2 KiB
Text
|
|
use builtin;
|
|
use str;
|
|
|
|
set edit:completion:arg-completer[my-app] = {|@words|
|
|
fn spaces {|n|
|
|
builtin:repeat $n ' ' | str:join ''
|
|
}
|
|
fn cand {|text desc|
|
|
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
|
|
}
|
|
var command = 'my-app'
|
|
for word $words[1..-1] {
|
|
if (str:has-prefix $word '-') {
|
|
break
|
|
}
|
|
set command = $command';'$word
|
|
}
|
|
var completions = [
|
|
&'my-app'= {
|
|
cand --choice 'choice'
|
|
cand --unknown 'unknown'
|
|
cand --other 'other'
|
|
cand -p 'p'
|
|
cand --path 'path'
|
|
cand -f 'f'
|
|
cand --file 'file'
|
|
cand -d 'd'
|
|
cand --dir 'dir'
|
|
cand -e 'e'
|
|
cand --exe 'exe'
|
|
cand --cmd-name 'cmd-name'
|
|
cand -c 'c'
|
|
cand --cmd 'cmd'
|
|
cand -u 'u'
|
|
cand --user 'user'
|
|
cand -H 'H'
|
|
cand --host 'host'
|
|
cand --url 'url'
|
|
cand --email 'email'
|
|
cand -h 'Print help'
|
|
cand --help 'Print help'
|
|
}
|
|
]
|
|
$completions[$command]
|
|
}
|