diff options
Diffstat (limited to 'docs/pages/advanced')
| -rw-r--r-- | docs/pages/advanced/1-completion.md | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/docs/pages/advanced/1-completion.md b/docs/pages/advanced/1-completion.md index 55b8b1d..ca1f621 100644 --- a/docs/pages/advanced/1-completion.md +++ b/docs/pages/advanced/1-completion.md @@ -11,13 +11,6 @@ Mingling's completion is **fully dynamic** — no static completion files, sugge # Cargo.toml [dependencies.mingling] features = ["comp"] - -[build-dependencies.mingling] -features = [ - "comp", - # Enable `build` for build-time support - "build" -] ``` ## How it works @@ -43,7 +36,7 @@ Use `#[completion(EntryType)]` to define completion logic for an Entry: @@@dispatcher!("greet", EntryGreet); #[completion(EntryGreet)] -fn complete_greet(ctx: &ShellContext) -> Suggest { +fn complete_greet(ctx: ShellContext) -> Suggest { if ctx.previous_word == "greet" { let mut items = BTreeSet::new(); items.insert(SuggestItem::new_with_desc("Alice".into(), "Likes to receive messages".into())); @@ -72,8 +65,18 @@ suggest! { ## Generate completion scripts -Call `build_comp_scripts` in `build.rs` to generate completion scripts (requires `builds` + `comp` features). +When the `comp` feature is enabled, `gen_program!()` automatically invokes `build_comp!()` at compile time, which generates the completion scripts (named after `CARGO_PKG_NAME`) into `target/mingling/`. + +If your binary name differs from the crate name, call `build_comp!()` manually with the binary name: +```rust +// Features: ["comp"] +@@@use mingling::macros::build_comp; +@@@fn example() { +build_comp!("mybin"); +@@@} +``` + See [example-completion](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-completion). <p align="center" style="font-size: 0.85em; color: gray;"> |
