diff options
Diffstat (limited to 'GETTING-STARTED.md')
| -rw-r--r-- | GETTING-STARTED.md | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md index 0730136..e4a706a 100644 --- a/GETTING-STARTED.md +++ b/GETTING-STARTED.md @@ -201,7 +201,7 @@ dispatcher!("greet", EntryGreet); pub struct ResultName((u8, String)); #[completion(EntryGreet)] -fn complete_greet(ctx: &ShellContext) -> Suggest { +fn complete_greet(ctx: ShellContext) -> Suggest { // Suggest positional arguments if ctx.previous_word == "greet" { return suggest! { @@ -212,12 +212,11 @@ fn complete_greet(ctx: &ShellContext) -> Suggest { } // Suggest flag arguments - if ctx.typing_argument() { + if ctx.current_word.starts_with('-') { return suggest! { "-r": "Number of repetitions", "--repeat": "Number of repetitions", - } - .strip_typed_argument(ctx); + }; } suggest!() // no suggestions @@ -235,13 +234,9 @@ fn main() { } ``` -In your `build.rs`, generate the shell scripts: - -```rust -// BUILD TIME -// Features: ["comp", "build"] -mingling::build::build_comp_scripts(env!("CARGO_PKG_NAME")).unwrap(); -``` +The completion scripts are generated automatically: with the `comp` feature enabled, +`gen_program!()` invokes `build_comp!()` at compile time and writes the shell scripts +(named after `CARGO_PKG_NAME`) into `target/mingling/`. For enum-based completions, use `suggest_enum!`: @@ -262,7 +257,7 @@ pub enum ProgrammingLanguages { } #[completion(EntryLang)] -fn complete_lang(_: &ShellContext) -> Suggest { +fn complete_lang(_: ShellContext) -> Suggest { suggest_enum!(ProgrammingLanguages) } ``` |
