diff --git a/clap_generate/src/generators/shells/elvish.rs b/clap_generate/src/generators/shells/elvish.rs index 5d282a29..a7c511db 100644 --- a/clap_generate/src/generators/shells/elvish.rs +++ b/clap_generate/src/generators/shells/elvish.rs @@ -22,6 +22,7 @@ impl Generator for Elvish { let result = format!( r#" +use str; edit:completion:arg-completer[{bin_name}] = [@words]{{ fn spaces [n]{{ repeat $n ' ' | joins '' @@ -31,7 +32,7 @@ edit:completion:arg-completer[{bin_name}] = [@words]{{ }} command = '{bin_name}' for word $words[1:-1] {{ - if (has-prefix $word '-') {{ + if (str:has-prefix $word '-') {{ break }} command = $command';'$word diff --git a/clap_generate/tests/completions/elvish.rs b/clap_generate/tests/completions/elvish.rs index 2c4a2065..1462881f 100644 --- a/clap_generate/tests/completions/elvish.rs +++ b/clap_generate/tests/completions/elvish.rs @@ -29,6 +29,7 @@ fn elvish() { } static ELVISH: &str = r#" +use str; edit:completion:arg-completer[my_app] = [@words]{ fn spaces [n]{ repeat $n ' ' | joins '' @@ -38,7 +39,7 @@ edit:completion:arg-completer[my_app] = [@words]{ } command = 'my_app' for word $words[1:-1] { - if (has-prefix $word '-') { + if (str:has-prefix $word '-') { break } command = $command';'$word @@ -90,6 +91,7 @@ fn build_app_special_commands() -> App<'static> { } static ELVISH_SPECIAL_CMDS: &str = r#" +use str; edit:completion:arg-completer[my_app] = [@words]{ fn spaces [n]{ repeat $n ' ' | joins '' @@ -99,7 +101,7 @@ edit:completion:arg-completer[my_app] = [@words]{ } command = 'my_app' for word $words[1:-1] { - if (has-prefix $word '-') { + if (str:has-prefix $word '-') { break } command = $command';'$word @@ -176,6 +178,7 @@ fn build_app_with_aliases() -> App<'static> { } static ELVISH_ALIASES: &str = r#" +use str; edit:completion:arg-completer[cmd] = [@words]{ fn spaces [n]{ repeat $n ' ' | joins '' @@ -185,7 +188,7 @@ edit:completion:arg-completer[cmd] = [@words]{ } command = 'cmd' for word $words[1:-1] { - if (has-prefix $word '-') { + if (str:has-prefix $word '-') { break } command = $command';'$word