aboutsummaryrefslogtreecommitdiff
path: root/docs/pages
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-14 00:42:05 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-14 00:42:05 +0800
commit9dde70fc4fb85a5be14a9429ba52fffe529317d3 (patch)
tree93009b07bfc06664a8024f2271106af8b88e56bc /docs/pages
parent886205215875f59b0019c2c870ec5ef977307130 (diff)
docs: update multiple dispatchers example to use chaining
Replace the `with_dispatchers` tuple syntax with chained `with_dispatcher` calls to match the current API and remove the obsolete section about tuple-based registration.
Diffstat (limited to 'docs/pages')
-rw-r--r--docs/pages/5-multiple-commands.md28
1 files changed, 2 insertions, 26 deletions
diff --git a/docs/pages/5-multiple-commands.md b/docs/pages/5-multiple-commands.md
index 0b71e49..17739e3 100644
--- a/docs/pages/5-multiple-commands.md
+++ b/docs/pages/5-multiple-commands.md
@@ -42,7 +42,8 @@ fn render_sum(result: ResultSum) {
fn main() {
let mut program = ThisProgram::new();
- program.with_dispatchers((CMDGreet, CMDAdd));
+ program.with_dispatcher(CMDGreet);
+ program.with_dispatcher(CMDAdd);
program.exec_and_exit();
}
@@ -58,31 +59,6 @@ Hello, Alice!
Sum: 6
```
-## Registering Multiple Dispatchers
-
-Notice `with_dispatchers`? When you need to register multiple dispatchers, just pass them as a tuple:
-
-```rust
-@@@dispatcher!("greet", CMDGreet => EntryGreet);
-@@@dispatcher!("add", CMDAdd => EntryAdd);
-@@@pack!(ResultGreeting = String);
-@@@pack!(ResultSum = i32);
-@@@#[chain] fn handle_greet(_args: EntryGreet) -> Next { ResultGreeting::new("ok".into()).into() }
-@@@#[renderer] fn render_greet(_greeting: ResultGreeting) -> RenderResult { RenderResult::new() }
-@@@#[chain] fn handle_add(_args: EntryAdd) -> Next { ResultSum::new(0).into() }
-@@@#[renderer] fn render_sum(_sum: ResultSum) -> RenderResult { RenderResult::new() }
-fn main() {
- let mut program = ThisProgram::new();
- program.with_dispatchers((CMDGreet, CMDAdd));
- program.exec_and_exit();
-}
-```
-
-This is equivalent to registering them one by one, same effect.
-
-> [!TIP]
-> The tuple supports up to 7 dispatchers. For more than 7, chain `with_dispatcher` calls instead.
-
## Subcommands
Multi-level commands work the same way—each dot-separated level is just part of the name: