1mod pages {
3 pub const ZIG: &str = include_str!("../manpages/zig.md");
4 pub const RUN: &str = include_str!("../manpages/run.md");
5 pub const CONTINUE: &str = include_str!("../manpages/continue.md");
6 pub const LISTEN: &str = include_str!("../manpages/listen.md");
7 pub const SERVE: &str = include_str!("../manpages/serve.md");
8 pub const WORKFLOW: &str = include_str!("../manpages/workflow.md");
9 pub const VALIDATE: &str = include_str!("../manpages/validate.md");
10 pub const RESOURCES: &str = include_str!("../manpages/resources.md");
11 pub const MEMORY: &str = include_str!("../manpages/memory.md");
12 pub const SELF: &str = include_str!("../manpages/self.md");
13}
14
15pub const TOPICS: &[(&str, &str)] = &[
17 ("zig", "Overview of the zig CLI"),
18 ("run", "Execute a .zwf/.zwfz workflow file"),
19 (
20 "continue",
21 "Resume the most recent step's agent conversation from the last run",
22 ),
23 ("listen", "Tail a running or completed zig session"),
24 ("serve", "Start an HTTP API server"),
25 (
26 "workflow",
27 "Manage workflows (list, show, create, update, delete, pack)",
28 ),
29 ("validate", "Validate a .zwf or .zwfz workflow file"),
30 (
31 "resources",
32 "Manage reference files advertised to step agents",
33 ),
34 (
35 "memory",
36 "Manage the memory scratch pad for workflows and steps",
37 ),
38 (
39 "self",
40 "Commands that act on the currently running zig/zag session",
41 ),
42];
43
44pub fn get(topic: &str) -> Option<&'static str> {
48 match topic {
49 "zig" => Some(pages::ZIG),
50 "run" => Some(pages::RUN),
51 "continue" => Some(pages::CONTINUE),
52 "listen" => Some(pages::LISTEN),
53 "serve" => Some(pages::SERVE),
54 "workflow" => Some(pages::WORKFLOW),
55 "validate" => Some(pages::VALIDATE),
56 "resources" => Some(pages::RESOURCES),
57 "memory" => Some(pages::MEMORY),
58 "self" => Some(pages::SELF),
59 _ => None,
60 }
61}
62
63pub fn list_topics() -> String {
65 let mut out = String::from("Available manpages:\n\n");
66 let max_name_len = TOPICS.iter().map(|(name, _)| name.len()).max().unwrap_or(0);
67 for (name, description) in TOPICS {
68 out.push_str(&format!(
69 " {name:<width$} {description}\n",
70 width = max_name_len
71 ));
72 }
73 out.push_str("\nUsage: zig man <topic>");
74 out
75}
76
77#[cfg(test)]
78#[path = "man_tests.rs"]
79mod tests;