2022-03-07 20:03:46 +00:00
|
|
|
|
|
|
|
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 'c'
|
|
|
|
cand -v 'v'
|
2022-08-08 21:08:47 +00:00
|
|
|
cand -h 'Print help information'
|
|
|
|
cand --help 'Print help information'
|
2022-03-07 20:03:46 +00:00
|
|
|
cand test 'Subcommand'
|
|
|
|
cand help 'Print this message or the help of the given subcommand(s)'
|
|
|
|
}
|
|
|
|
&'my-app;test'= {
|
|
|
|
cand -d 'd'
|
2022-08-08 21:08:47 +00:00
|
|
|
cand -c 'c'
|
2022-03-07 20:03:46 +00:00
|
|
|
cand -h 'Print help information'
|
|
|
|
cand --help 'Print help information'
|
|
|
|
}
|
|
|
|
&'my-app;help'= {
|
2022-08-25 05:44:07 +00:00
|
|
|
cand test 'Subcommand'
|
|
|
|
cand help 'Print this message or the help of the given subcommand(s)'
|
|
|
|
}
|
|
|
|
&'my-app;help;test'= {
|
|
|
|
}
|
|
|
|
&'my-app;help;help'= {
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
$completions[$command]
|
|
|
|
}
|