diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-11 16:03:20 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-11 16:03:20 +0800 |
| commit | 810536fb1f068f969af316be0450a1edacfe8e28 (patch) | |
| tree | ece6a67f196afda364d4443e17687c2076e132c4 /docs/pages/10-help.md | |
| parent | 4bf23c20f2d7cdfcc988b654a93abae1cd211ad8 (diff) | |
docs: migrate renderers from `r_println!` to `RenderResult` return type
Diffstat (limited to 'docs/pages/10-help.md')
| -rw-r--r-- | docs/pages/10-help.md | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/docs/pages/10-help.md b/docs/pages/10-help.md index 2f3b74f..7ef1f26 100644 --- a/docs/pages/10-help.md +++ b/docs/pages/10-help.md @@ -15,9 +15,11 @@ Write a help function directly for an Entry: @@@use mingling::macros::help; @@@dispatcher!("greet", CMDGreet => EntryGreet); #[help] -fn help_greet(_entry: EntryGreet) { - r_println!("Usage: greet [name]"); - r_println!("Say hello to someone."); +fn help_greet(entry: EntryGreet) -> RenderResult { + let mut r = RenderResult::new(); + writeln!(r, "Usage: greet [name]").ok(); + writeln!(r, "Say hello to someone.").ok(); + r } ``` @@ -32,10 +34,12 @@ You can also write help for `ErrorDispatcherNotFound` as the "root help": @@@use mingling::macros::help; // Triggered when user passes --help directly #[help] -fn help_root(entry: ErrorDispatcherNotFound) { - r_println!("Usage: my-cli <command>"); - r_println!("Commands:"); - r_println!(" greet Say hello"); +fn help_root(entry: ErrorDispatcherNotFound) -> RenderResult { + let mut r = RenderResult::new(); + writeln!(r, "Usage: my-cli <command>").ok(); + writeln!(r, "Commands:").ok(); + writeln!(r, " greet Say hello").ok(); + r } ``` |
