1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
//! This module provides help information for the `todolist` command line program
use crate::{EntryAdd, EntryClean, EntryComplete, EntryList, ErrorDispatcherNotFound};
use mingling::{RenderResult, macros::help};
use std::io::Write;
/// Shows the global help message.
#[help]
pub fn help_global(_p: ErrorDispatcherNotFound) -> RenderResult {
let mut render_result = RenderResult::new();
writeln!(
render_result,
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)"
)
.ok();
render_result
}
/// Shows help for the `add` command.
#[help]
pub fn help_add(_p: EntryAdd) -> RenderResult {
let mut render_result = RenderResult::new();
writeln!(
render_result,
r"Usage: todolist add [task description]
Add a new task to the todo list.
Example:
todolist add 'Buy groceries'
todolist add 'Finish Rust project'"
)
.ok();
render_result
}
/// Shows help for the `list` command.
#[help]
pub fn help_list(_p: EntryList) -> RenderResult {
let mut render_result = RenderResult::new();
writeln!(
render_result,
r"Usage: todolist list
List all tasks.
Example:
todolist list"
)
.ok();
render_result
}
/// Shows help for the `complete` command.
#[help]
pub fn help_complete(_p: EntryComplete) -> RenderResult {
let mut render_result = RenderResult::new();
writeln!(
render_result,
r"Usage: todolist complete [task_id]
Mark a task as complete by its ID.
Example:
todolist complete 1
todolist complete 3"
)
.ok();
render_result
}
/// Shows help for the `clean` command.
#[help]
pub fn help_clean(_p: EntryClean) -> RenderResult {
let mut render_result = RenderResult::new();
writeln!(
render_result,
r"Usage: todolist clean
Remove all completed tasks from the list.
Example:
todolist clean"
)
.ok();
render_result
}
|