-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.rs
More file actions
28 lines (22 loc) · 700 Bytes
/
build.rs
File metadata and controls
28 lines (22 loc) · 700 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
#[cfg(feature = "cli")]
include!("src/cli.rs");
#[cfg(feature = "cli")]
fn main() -> Result<(), clap::Error> {
use clap::CommandFactory;
use clap_complete::{generate_to, Shell};
use std::{fs, path, process::exit};
let out_dir = option_env!("OUT_DIR").unwrap_or_else(|| {
exit(0);
});
let dir = path::Path::new(&out_dir).join("completions/");
if !dir.exists() {
fs::create_dir(dir.clone()).expect("Failed to create 'completions' directory.");
}
let mut cmd = Opt::command();
for &shell in Shell::value_variants() {
generate_to(shell, &mut cmd, "lolcrab", dir.clone())?;
}
Ok(())
}
#[cfg(not(feature = "cli"))]
fn main() {}