mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 23:32:32 +00:00
27 lines
599 B
Text
27 lines
599 B
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 -h 'Print help'
|
||
|
cand --help 'Print help'
|
||
|
}
|
||
|
]
|
||
|
$completions[$command]
|
||
|
}
|