clap/clap_complete/tests/snapshots/feature_sample.elvish

50 lines
1.4 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 -c 'some config file'
cand -C 'some config file'
cand --config 'some config file'
cand --conf 'some config file'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
cand test 'tests things'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'my-app;test'= {
cand --case 'the case to test'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
}
&'my-app;help'= {
cand test 'tests things'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'my-app;help;test'= {
}
&'my-app;help;help'= {
}
]
$completions[$command]
}