-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.rs
62 lines (46 loc) · 1.64 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::io::{Error, ErrorKind};
use std::path::PathBuf;
use std::{env, fs};
use clap::CommandFactory;
use clap_complete::{generate_to, shells};
use clap_mangen::Man;
include!("src/cli.rs");
fn main() -> Result<(), Error> {
let outdir = PathBuf::from(env::var_os("OUT_DIR").ok_or(ErrorKind::NotFound)?);
let mut cmd = Cli::command();
let bash_path = generate_to(shells::Bash, &mut cmd, "rhino-config", outdir.clone())?;
println!(
"cargo:warning=completion file for bash generated: {:?}",
bash_path
);
let elvish_path = generate_to(shells::Elvish, &mut cmd, "rhino-config", outdir.clone())?;
println!(
"cargo:warning=completion file for elvish generated: {:?}",
elvish_path
);
let fish_path = generate_to(shells::Fish, &mut cmd, "rhino-config", outdir.clone())?;
println!(
"cargo:warning=completion file for fish generated: {:?}",
fish_path
);
let powershell_path =
generate_to(shells::PowerShell, &mut cmd, "rhino-config", outdir.clone())?;
println!(
"cargo:warning=completion file for powershell generated: {:?}",
powershell_path
);
// let zsh_path = generate_to(
// shells::Zsh,
// &mut cmd,
// "rhino-config",
// outdir.clone(),
// )?;
// println!("cargo:warning=completion file for zsh generated: {:?}", zsh_path);
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
let man_path = outdir.join("rhino-config.1");
fs::write(&man_path, buffer)?;
println!("cargo:warning=man page generated: {:?}", &man_path);
Ok(())
}