mirror of
https://github.com/clap-rs/clap
synced 2024-11-11 07:14:15 +00:00
Merge pull request #2783 from cherryblossom000/elvish-completions-fix
Fix Elvish completions generation
This commit is contained in:
commit
9c214a66dc
2 changed files with 20 additions and 20 deletions
|
@ -25,21 +25,21 @@ impl Generator for Elvish {
|
|||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[{bin_name}] = [@words]{{
|
||||
set edit:completion:arg-completer[{bin_name}] = [@words]{{
|
||||
fn spaces [n]{{
|
||||
builtin:repeat $n ' ' | str:join ''
|
||||
}}
|
||||
fn cand [text desc]{{
|
||||
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}}
|
||||
command = '{bin_name}'
|
||||
var command = '{bin_name}'
|
||||
for word $words[1..-1] {{
|
||||
if (str:has-prefix $word '-') {{
|
||||
break
|
||||
}}
|
||||
command = $command';'$word
|
||||
set command = $command';'$word
|
||||
}}
|
||||
completions = [{subcommands_cases}
|
||||
var completions = [{subcommands_cases}
|
||||
]
|
||||
$completions[$command]
|
||||
}}
|
||||
|
|
|
@ -32,21 +32,21 @@ static ELVISH: &str = r#"
|
|||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[my_app] = [@words]{
|
||||
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-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}
|
||||
command = 'my_app'
|
||||
var command = 'my_app'
|
||||
for word $words[1..-1] {
|
||||
if (str:has-prefix $word '-') {
|
||||
break
|
||||
}
|
||||
command = $command';'$word
|
||||
set command = $command';'$word
|
||||
}
|
||||
completions = [
|
||||
var completions = [
|
||||
&'my_app'= {
|
||||
cand -h 'Print help information'
|
||||
cand --help 'Print help information'
|
||||
|
@ -96,21 +96,21 @@ static ELVISH_SPECIAL_CMDS: &str = r#"
|
|||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[my_app] = [@words]{
|
||||
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-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}
|
||||
command = 'my_app'
|
||||
var command = 'my_app'
|
||||
for word $words[1..-1] {
|
||||
if (str:has-prefix $word '-') {
|
||||
break
|
||||
}
|
||||
command = $command';'$word
|
||||
set command = $command';'$word
|
||||
}
|
||||
completions = [
|
||||
var completions = [
|
||||
&'my_app'= {
|
||||
cand -h 'Print help information'
|
||||
cand --help 'Print help information'
|
||||
|
@ -185,21 +185,21 @@ static ELVISH_ALIASES: &str = r#"
|
|||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[cmd] = [@words]{
|
||||
set edit:completion:arg-completer[cmd] = [@words]{
|
||||
fn spaces [n]{
|
||||
builtin:repeat $n ' ' | str:join ''
|
||||
}
|
||||
fn cand [text desc]{
|
||||
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}
|
||||
command = 'cmd'
|
||||
var command = 'cmd'
|
||||
for word $words[1..-1] {
|
||||
if (str:has-prefix $word '-') {
|
||||
break
|
||||
}
|
||||
command = $command';'$word
|
||||
set command = $command';'$word
|
||||
}
|
||||
completions = [
|
||||
var completions = [
|
||||
&'cmd'= {
|
||||
cand -o 'cmd option'
|
||||
cand -O 'cmd option'
|
||||
|
|
Loading…
Reference in a new issue