-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.rs
45 lines (39 loc) · 981 Bytes
/
build.rs
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
34
35
36
37
38
39
40
41
42
43
44
45
use clap_complete::Shell;
#[allow(dead_code)]
#[path = "src/cli.rs"]
mod cli;
fn main() -> std::io::Result<()> {
println!("cargo:rerun-if-changed=src/cli.rs");
let out_dir = std::path::PathBuf::from(
std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?,
);
let man = clap_mangen::Man::new(cli::build());
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(out_dir.join("mmdu.1"), buffer)?;
clap_complete::generate_to(
Shell::Bash,
&mut cli::build(),
"mmdu",
&out_dir,
)?;
clap_complete::generate_to(
Shell::Fish,
&mut cli::build(),
"mmdu",
&out_dir,
)?;
clap_complete::generate_to(
Shell::Elvish,
&mut cli::build(),
"mmdu",
&out_dir,
)?;
clap_complete::generate_to(
Shell::Zsh,
&mut cli::build(),
"mmdu",
&out_dir,
)?;
Ok(())
}