diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-20 09:50:28 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-20 09:50:28 +0800 |
| commit | c385dcf15930d2754b68c2794986ad30fc65c141 (patch) | |
| tree | 2fed45ade07d96d195b9f9a35a1de0aeda11ee5e /docs/pages/5-multiple-commands.md | |
| parent | 7b3a1d7fd9f60b91a7f9602374c081882d46facc (diff) | |
docs: migrate renderer examples to buffer macro and update docs
Update all documentation and code examples to use the new
`#[renderer(buffer)]`
pattern with `r_println!` instead of manually constructing
`RenderResult`
with `writeln!`.
Diffstat (limited to 'docs/pages/5-multiple-commands.md')
| -rw-r--r-- | docs/pages/5-multiple-commands.md | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/docs/pages/5-multiple-commands.md b/docs/pages/5-multiple-commands.md index d9a335a..0b71e49 100644 --- a/docs/pages/5-multiple-commands.md +++ b/docs/pages/5-multiple-commands.md @@ -10,6 +10,7 @@ Real-world CLIs rarely have just one command. Let's extend our previous greet pr Work in the same project: ```rust +@@@use mingling::macros::buffer; // Declare two commands dispatcher!("greet", CMDGreet => EntryGreet); dispatcher!("add", CMDAdd => EntryAdd); @@ -29,18 +30,14 @@ fn handle_add(args: EntryAdd) -> Next { ResultSum::new(sum).into() } -#[renderer] -fn render_greet(result: ResultGreeting) -> RenderResult { - let mut r = RenderResult::new(); - writeln!(r, "Hello, {}!", *result).ok(); - r +#[renderer(buffer)] +fn render_greet(result: ResultGreeting) { + r_println!("Hello, {}!", *result); } -#[renderer] -fn render_sum(result: ResultSum) -> RenderResult { - let mut r = RenderResult::new(); - writeln!(r, "Sum: {}", *result).ok(); - r +#[renderer(buffer)] +fn render_sum(result: ResultSum) { + r_println!("Sum: {}", *result); } fn main() { |
