aboutsummaryrefslogtreecommitdiff
path: root/mingling/src/example_docs.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-12 01:06:24 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-12 01:06:24 +0800
commit7c496151f571b872da523f4c46369751be6f4ca1 (patch)
treee71d2aeb7a16f38996b9d68fe77259269ef25c8f /mingling/src/example_docs.rs
parent5e10b03acb0312155d0d76e06d366bcf76cb9f27 (diff)
Add ShellContext helper methods for completion logic
Diffstat (limited to 'mingling/src/example_docs.rs')
-rw-r--r--mingling/src/example_docs.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index 2e3f689..79a0626 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -119,20 +119,21 @@ pub mod example_basic {}
///
/// #[completion(FruitEntry)]
/// fn comp_fruit_command(ctx: &ShellContext) -> Suggest {
-/// if ctx.current_word.starts_with("-") {
-/// return suggest! {
-/// "--name": "Fruit name",
-/// "--type": "Fruit type"
-/// };
-/// }
-/// if ctx.previous_word == "--name" {
+/// if ctx.filling_argument_first("--name") {
/// return suggest!();
/// }
-/// if ctx.previous_word == "--type" {
+/// if ctx.filling_argument_first("--type") {
/// return suggest! {
/// "apple", "banana"
/// };
/// }
+/// if ctx.typing_argument() {
+/// return suggest! {
+/// "--name": "Fruit name",
+/// "--type": "Fruit type"
+/// }
+/// .strip_typed_argument(ctx);
+/// }
/// return suggest!();
/// }
///