mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Merge pull request #2436 from ajeetdsouza/ajeet/elvish
Fix completions for Elvish shell
This commit is contained in:
commit
9be6db5999
2 changed files with 24 additions and 12 deletions
|
@ -22,16 +22,19 @@ impl Generator for Elvish {
|
|||
|
||||
let result = format!(
|
||||
r#"
|
||||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[{bin_name}] = [@words]{{
|
||||
fn spaces [n]{{
|
||||
repeat $n ' ' | joins ''
|
||||
builtin:repeat $n ' ' | str:join ''
|
||||
}}
|
||||
fn cand [text desc]{{
|
||||
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}}
|
||||
command = '{bin_name}'
|
||||
for word $words[1:-1] {{
|
||||
if (has-prefix $word '-') {{
|
||||
for word $words[1..-1] {{
|
||||
if (str:has-prefix $word '-') {{
|
||||
break
|
||||
}}
|
||||
command = $command';'$word
|
||||
|
|
|
@ -29,16 +29,19 @@ fn elvish() {
|
|||
}
|
||||
|
||||
static ELVISH: &str = r#"
|
||||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[my_app] = [@words]{
|
||||
fn spaces [n]{
|
||||
repeat $n ' ' | joins ''
|
||||
builtin:repeat $n ' ' | str:join ''
|
||||
}
|
||||
fn cand [text desc]{
|
||||
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}
|
||||
command = 'my_app'
|
||||
for word $words[1:-1] {
|
||||
if (has-prefix $word '-') {
|
||||
for word $words[1..-1] {
|
||||
if (str:has-prefix $word '-') {
|
||||
break
|
||||
}
|
||||
command = $command';'$word
|
||||
|
@ -90,16 +93,19 @@ fn build_app_special_commands() -> App<'static> {
|
|||
}
|
||||
|
||||
static ELVISH_SPECIAL_CMDS: &str = r#"
|
||||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[my_app] = [@words]{
|
||||
fn spaces [n]{
|
||||
repeat $n ' ' | joins ''
|
||||
builtin:repeat $n ' ' | str:join ''
|
||||
}
|
||||
fn cand [text desc]{
|
||||
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}
|
||||
command = 'my_app'
|
||||
for word $words[1:-1] {
|
||||
if (has-prefix $word '-') {
|
||||
for word $words[1..-1] {
|
||||
if (str:has-prefix $word '-') {
|
||||
break
|
||||
}
|
||||
command = $command';'$word
|
||||
|
@ -176,16 +182,19 @@ fn build_app_with_aliases() -> App<'static> {
|
|||
}
|
||||
|
||||
static ELVISH_ALIASES: &str = r#"
|
||||
use builtin;
|
||||
use str;
|
||||
|
||||
edit:completion:arg-completer[cmd] = [@words]{
|
||||
fn spaces [n]{
|
||||
repeat $n ' ' | joins ''
|
||||
builtin:repeat $n ' ' | str:join ''
|
||||
}
|
||||
fn cand [text desc]{
|
||||
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}
|
||||
command = 'cmd'
|
||||
for word $words[1:-1] {
|
||||
if (has-prefix $word '-') {
|
||||
for word $words[1..-1] {
|
||||
if (str:has-prefix $word '-') {
|
||||
break
|
||||
}
|
||||
command = $command';'$word
|
||||
|
|
Loading…
Reference in a new issue