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 DESCRIBE: &str = include_str!("../manpages/describe.md");
9 pub const VALIDATE: &str = include_str!("../manpages/validate.md");
10 pub const ZUG: &str = include_str!("../manpages/zug.md");
11 pub const PATTERNS: &str = include_str!("../manpages/patterns.md");
12 pub const VARIABLES: &str = include_str!("../manpages/variables.md");
13 pub const CONDITIONS: &str = include_str!("../manpages/conditions.md");
14 pub const RESOURCES: &str = include_str!("../manpages/resources.md");
15}
16
17pub const TOPICS: &[(&str, &str)] = &[
19 ("zig", "Overview of the zig CLI"),
20 ("run", "Execute a .zug workflow file"),
21 ("listen", "Tail a running or completed zig session"),
22 ("serve", "Start an HTTP API server"),
23 (
24 "workflow",
25 "Manage workflows (list, show, create, delete, pack)",
26 ),
27 ("describe", "Generate a .zug file from a prompt"),
28 ("validate", "Validate a .zug workflow file"),
29 ("zug", "The .zug workflow format"),
30 ("patterns", "Orchestration patterns"),
31 ("variables", "Variable system and data flow"),
32 ("conditions", "Condition expressions"),
33 ("resources", "Reference files advertised to step agents"),
34];
35
36pub fn get(topic: &str) -> Option<&'static str> {
40 match topic {
41 "zig" => Some(pages::ZIG),
42 "run" => Some(pages::RUN),
43 "listen" => Some(pages::LISTEN),
44 "serve" => Some(pages::SERVE),
45 "workflow" => Some(pages::WORKFLOW),
46 "describe" => Some(pages::DESCRIBE),
47 "validate" => Some(pages::VALIDATE),
48 "zug" => Some(pages::ZUG),
49 "patterns" => Some(pages::PATTERNS),
50 "variables" => Some(pages::VARIABLES),
51 "conditions" => Some(pages::CONDITIONS),
52 "resources" => Some(pages::RESOURCES),
53 _ => None,
54 }
55}
56
57pub fn list_topics() -> String {
59 let mut out = String::from("Available manpages:\n\n");
60 let max_name_len = TOPICS.iter().map(|(name, _)| name.len()).max().unwrap_or(0);
61 for (name, description) in TOPICS {
62 out.push_str(&format!(
63 " {name:<width$} {description}\n",
64 width = max_name_len
65 ));
66 }
67 out.push_str("\nUsage: zig man <topic>");
68 out
69}
70
71#[cfg(test)]
72#[path = "man_tests.rs"]
73mod tests;