1use std::process::Command;
2use which::which;
3
4const DEFAULT_TARGET_DIR: &str = "../../target/release/assets";
5
6pub fn build_manpage(manpage: &str, source: &str) {
7 match which("asciidoctor") {
8 Err(why) => eprintln!("couldn't compile asciidoctor: {}", why),
9 Ok(command) => {
10 let target_dir = match std::env::var("CARGO_TARGET_DIR") {
11 Ok(dir) => dir,
12 _ => DEFAULT_TARGET_DIR.to_string(),
13 };
14
15 let result = Command::new(command)
16 .arg("-b")
17 .arg("manpage")
18 .arg("-o")
19 .arg(format!("{}/{}", target_dir, manpage))
20 .arg(format!("docs/{}", source))
21 .output()
22 .expect("asciidoctor failed");
23
24 if result.status.success() {
25 Command::new("gzip")
26 .arg(format!("{}/{}", target_dir, manpage))
27 .output()
28 .expect("Fail for gzip running");
29 }
30 }
31 };
32}