-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.rs
25 lines (21 loc) · 1.02 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
use clap::Shell;
use std::fs;
use std::path::PathBuf;
#[allow(dead_code)]
#[path = "src/cli.rs"]
mod cli;
fn main() {
// OUT_DIR is set by Cargo and is where all generated files should go:
// https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script
// https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
let out_dir = std::env::var_os("OUT_DIR").unwrap();
let mut completions_dir = PathBuf::from(&out_dir);
completions_dir.push("completions");
fs::create_dir_all(&completions_dir).unwrap();
let mut app = cli::build_cli();
app.gen_completions(cli::binary_name(), Shell::Bash, &completions_dir);
app.gen_completions(cli::binary_name(), Shell::Elvish, &completions_dir);
app.gen_completions(cli::binary_name(), Shell::Fish, &completions_dir);
app.gen_completions(cli::binary_name(), Shell::PowerShell, &completions_dir);
app.gen_completions(cli::binary_name(), Shell::Zsh, &completions_dir);
}