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