rusmes_cli/commands/
man.rs1use anyhow::Result;
4use clap::CommandFactory;
5use clap_mangen::Man;
6use std::io::Write;
7
8pub fn run<A>() -> Result<()>
16where
17 A: CommandFactory,
18{
19 let cmd = A::command();
20 let man = Man::new(cmd);
21 let mut stdout = std::io::stdout();
22 man.render(&mut stdout)?;
23 stdout.flush()?;
24 Ok(())
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
34 fn man_page_produces_valid_roff() {
35 use crate::CliApp;
36 use std::io::Write;
37
38 let cmd = CliApp::command();
39 let man = Man::new(cmd);
40 let mut buf: Vec<u8> = Vec::new();
41 man.render(&mut buf).expect("man page render");
42 buf.flush().ok();
43
44 let output = String::from_utf8(buf).expect("utf-8");
45 assert!(
46 output.contains(".TH"),
47 "man page output should contain the .TH roff macro — got:\n{output}"
48 );
49 }
50}