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 LISTEN: &str = include_str!("../manpages/listen.md");
6 pub const SERVE: &str = include_str!("../manpages/serve.md");
7 pub const WORKFLOW: &str = include_str!("../manpages/workflow.md");
8 pub const VALIDATE: &str = include_str!("../manpages/validate.md");
9 pub const RESOURCES: &str = include_str!("../manpages/resources.md");
10 pub const MEMORY: &str = include_str!("../manpages/memory.md");
11}
12
13pub const TOPICS: &[(&str, &str)] = &[
15 ("zig", "Overview of the zig CLI"),
16 ("run", "Execute a .zwf/.zwfz workflow file"),
17 ("listen", "Tail a running or completed zig session"),
18 ("serve", "Start an HTTP API server"),
19 (
20 "workflow",
21 "Manage workflows (list, show, create, update, delete, pack)",
22 ),
23 ("validate", "Validate a .zwf or .zwfz workflow file"),
24 (
25 "resources",
26 "Manage reference files advertised to step agents",
27 ),
28 (
29 "memory",
30 "Manage the memory scratch pad for workflows and steps",
31 ),
32];
33
34pub fn get(topic: &str) -> Option<&'static str> {
38 match topic {
39 "zig" => Some(pages::ZIG),
40 "run" => Some(pages::RUN),
41 "listen" => Some(pages::LISTEN),
42 "serve" => Some(pages::SERVE),
43 "workflow" => Some(pages::WORKFLOW),
44 "validate" => Some(pages::VALIDATE),
45 "resources" => Some(pages::RESOURCES),
46 "memory" => Some(pages::MEMORY),
47 _ => None,
48 }
49}
50
51pub fn list_topics() -> String {
53 let mut out = String::from("Available manpages:\n\n");
54 let max_name_len = TOPICS.iter().map(|(name, _)| name.len()).max().unwrap_or(0);
55 for (name, description) in TOPICS {
56 out.push_str(&format!(
57 " {name:<width$} {description}\n",
58 width = max_name_len
59 ));
60 }
61 out.push_str("\nUsage: zig man <topic>");
62 out
63}
64
65#[cfg(test)]
66#[path = "man_tests.rs"]
67mod tests;