-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.rs
41 lines (34 loc) · 845 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
#![allow(dead_code)]
use std::env;
use std::path::PathBuf;
use clap::CommandFactory;
use clap_complete::{generate_to, Shell};
include!("src/cli_opt.rs");
fn main() {
let outdir = match env::var_os("OUT_DIR") {
None => return,
Some(outdir) => outdir,
};
let comp_dir = PathBuf::from(outdir)
.ancestors()
.nth(2)
.map(|p| p.join("completions"))
.expect("Unable to process completions path");
if !comp_dir.exists() {
std::fs::create_dir(&comp_dir).expect("Unable to create completions dir");
}
generate_to(
Shell::Bash,
&mut Opt::command(),
"rust-rpm-prov",
comp_dir.clone(),
)
.ok();
generate_to(
Shell::Zsh,
&mut Opt::command(),
"rust-rpm-prov",
comp_dir.clone(),
)
.ok();
}