mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
58b0c504d8
Emit the user-defined value terminator into the zsh completion pattern to avoid doubled rest-arguments definitions: $ my-app <TAB> _arguments:comparguments:325: doubled rest argument definition: *::second -- second set of of multi-length arguments: https://github.com/clap-rs/clap/issues/3266#issuecomment-1007901407 noted that including the value terminator is one step towards a robust solution for handling multiple multi-valued arguments. This change does not yet handle automatically detecting when a value terminator is needed, but it does add tests to ensure that user-specified value terminators are used on zsh. Related-to: #3022 Signed-off-by: David Aguilar <davvid@gmail.com>
26 lines
599 B
Text
26 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]
|
|
}
|