clap/clap_complete/tests/snapshots/value_hint.elvish

47 lines
1.2 KiB
Text
Raw Normal View History

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]
}