-
Hello, I have been struggling a bit with this and I am still not sure if I am doing it the right way : fn main() -> std::io::Result<()> {
std::fs::create_dir("man_pages").unwrap();
let mut command = cocogitto::cli::Cli::command();
let cmd_name = command.get_name().to_string();
for subcommand in command.get_subcommands_mut() {
let name = subcommand.get_name().clone();
let name = format!("{}-{}", cmd_name, name);
let sub = subcommand.clone().name(&name);
let man = clap_mangen::Man::new(sub);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer).unwrap();
std::fs::write(PathBuf::from("man_pages").join(&format!("{}.1", name)), buffer).unwrap();
}
let man = clap_mangen::Man::new(command);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(PathBuf::from("man_pages").join(&format!("{}.1", cmd_name)), buffer)?;
Ok(())
} It feels a bit hacky to mutate the sub commands so the man pages title get prefixed with the parent command. Could be nice to had an example in the repo though. |
Beta Was this translation helpful? Give feedback.
Answered by
epage
Apr 14, 2022
Replies: 1 comment 1 reply
Answer selected by
oknozor
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See #3603