-
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathbuild.rs
More file actions
32 lines (26 loc) · 759 Bytes
/
build.rs
File metadata and controls
32 lines (26 loc) · 759 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
use std::{
env,
fs::{File, create_dir_all},
path::Path,
};
use clap::{CommandFactory, ValueEnum};
use clap_complete::{Shell, generate_to};
use clap_mangen::Man;
mod cli {
include!("src/cli.rs");
}
fn main() {
println!("cargo:rerun-if-env-changed=GEN_ARTIFACTS");
println!("cargo:rustc-cfg=not_build");
if let Some(dir) = env::var_os("GEN_ARTIFACTS") {
let out = &Path::new(&dir);
create_dir_all(out).unwrap();
let cmd = &mut cli::Opts::command();
Man::new(cmd.clone())
.render(&mut File::create(out.join("nix-init.1")).unwrap())
.unwrap();
for shell in Shell::value_variants() {
generate_to(*shell, cmd, "nix-init", out).unwrap();
}
}
}