-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
33 lines (29 loc) · 903 Bytes
/
build.rs
File metadata and controls
33 lines (29 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::{fs, io::Write};
include!("src/cli.rs");
fn main() -> std::io::Result<()> {
generate_man::<Cli>()?;
generate_markdown::<Cli>()?;
Ok(())
}
fn generate_man<C: clap::CommandFactory>() -> std::io::Result<()> {
let command = C::command();
let out_dir: PathBuf = "doc".into();
let name = command.get_name();
let name = if name == "yage" {
"yage.1".to_owned()
} else {
format!("yage-{}.1", command.get_name())
};
let fname = out_dir.join(name);
let man = clap_mangen::Man::new(command);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(fname, buffer)?;
Ok(())
}
fn generate_markdown<C: clap::CommandFactory>() -> std::io::Result<()> {
let md = clap_markdown::help_markdown::<C>();
let mut f = fs::File::create("doc/CommandLineHelp.md")?;
write!(f, "{md}")?;
Ok(())
}