mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
0d0be51606
* Copy hide flag * Revert global args special handling. Another commit will address the issue of whether global args should be included in help subtrees.
47 lines
1.2 KiB
Text
47 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 -c 'c'
|
|
cand -v 'v'
|
|
cand -h 'Print help information'
|
|
cand --help 'Print help information'
|
|
cand test 'Subcommand'
|
|
cand help 'Print this message or the help of the given subcommand(s)'
|
|
}
|
|
&'my-app;test'= {
|
|
cand -d 'd'
|
|
cand -c 'c'
|
|
cand -h 'Print help information'
|
|
cand --help 'Print help information'
|
|
}
|
|
&'my-app;help'= {
|
|
cand -c 'c'
|
|
cand test 'Subcommand'
|
|
cand help 'Print this message or the help of the given subcommand(s)'
|
|
}
|
|
&'my-app;help;test'= {
|
|
cand -c 'c'
|
|
}
|
|
&'my-app;help;help'= {
|
|
cand -c 'c'
|
|
}
|
|
]
|
|
$completions[$command]
|
|
}
|