From 4867dae1235040455624ea792557c72fe7a9b6bf Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 12 Apr 2026 01:29:04 +0800 Subject: Add comments to example completion function --- examples/example-completion/src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'examples/example-completion/src') diff --git a/examples/example-completion/src/main.rs b/examples/example-completion/src/main.rs index a15ad84..86a00ca 100644 --- a/examples/example-completion/src/main.rs +++ b/examples/example-completion/src/main.rs @@ -36,21 +36,27 @@ dispatcher!("fruit", FruitCommand => FruitEntry); #[completion(FruitEntry)] fn comp_fruit_command(ctx: &ShellContext) -> Suggest { + // When the user is filling "--name" for the first time if ctx.filling_argument_first("--name") { return suggest!(); } + // When the user is filling "--type" for the first time if ctx.filling_argument_first("--type") { return suggest! { "apple", "banana" }; } + // When the user is typing an argument if ctx.typing_argument() { return suggest! { "--name": "Fruit name", "--type": "Fruit type" } + // Strip already typed arguments .strip_typed_argument(ctx); } + + // Return empty suggestion, indicating Shell should not perform any completion logic return suggest!(); } -- cgit