diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-09 06:34:55 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-09 06:34:55 +0800 |
| commit | ab796e81ab4e3e9fa1a26f8217635eebec658b5e (patch) | |
| tree | bbaf957bd9f952e93b767f5d1228d3c99d450a0a /examples/full-todolist/src/help.rs | |
| parent | 78f282007980fe9c9ef143a6bc6fb76282957ab6 (diff) | |
Add full-todolist example project
Diffstat (limited to 'examples/full-todolist/src/help.rs')
| -rw-r--r-- | examples/full-todolist/src/help.rs | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/examples/full-todolist/src/help.rs b/examples/full-todolist/src/help.rs new file mode 100644 index 0000000..ab33176 --- /dev/null +++ b/examples/full-todolist/src/help.rs @@ -0,0 +1,93 @@ +//! This module provides help information for the `todolist` command line program + +use mingling::macros::{help, r_println}; + +use crate::{EntryAdd, EntryClean, EntryComplete, EntryList, ErrorDispatcherNotFound}; + +#[help] +pub fn help_global(_p: ErrorDispatcherNotFound) { + r_println!( + "{}", + r" +Usage: todolist [command] [args] + +Commands: + add -- Add a new task + list -- List all tasks + complete -- Mark a task as complete + clean -- Clean up completed tasks + +Args: + -h, --help -- Show this help message + -V, --version -- Show the version + -A, --all -- All tasks (Clean all / List all) + " + .trim() + ); +} + +#[help] +pub fn help_add(_p: EntryAdd) { + r_println!( + "{}", + r" +Usage: todolist add [task description] + +Add a new task to the todo list. + +Example: + todolist add 'Buy groceries' + todolist add 'Finish Rust project' + " + .trim() + ); +} + +#[help] +pub fn help_list(_p: EntryList) { + r_println!( + "{}", + r" +Usage: todolist list + +List all tasks. + +Example: + todolist list + " + .trim() + ); +} + +#[help] +pub fn help_complete(_p: EntryComplete) { + r_println!( + "{}", + r" +Usage: todolist complete [task_id] + +Mark a task as complete by its ID. + +Example: + todolist complete 1 + todolist complete 3 + " + .trim() + ); +} + +#[help] +pub fn help_clean(_p: EntryClean) { + r_println!( + "{}", + r" +Usage: todolist clean + +Remove all completed tasks from the list. + +Example: + todolist clean + " + .trim() + ); +} |
