hyperfine/build.rs

26 lines
584 B
Rust
Raw Normal View History

2020-05-21 15:37:10 +03:00
use std::fs;
2022-02-03 22:50:39 +03:00
use clap_complete::{generate_to, Shell};
2020-05-21 15:37:10 +03:00
2022-02-22 16:04:07 +03:00
include!("src/cli.rs");
2020-05-21 15:37:10 +03:00
fn main() {
2021-06-12 00:44:11 +03:00
let var = std::env::var_os("SHELL_COMPLETIONS_DIR").or_else(|| std::env::var_os("OUT_DIR"));
2020-05-21 15:37:10 +03:00
let outdir = match var {
None => return,
Some(outdir) => outdir,
};
fs::create_dir_all(&outdir).unwrap();
2022-02-22 16:04:07 +03:00
let mut command = build_command();
2022-02-03 22:50:39 +03:00
for shell in [
Shell::Bash,
Shell::Fish,
Shell::Zsh,
Shell::PowerShell,
Shell::Elvish,
] {
2022-02-22 16:04:07 +03:00
generate_to(shell, &mut command, "hyperfine", &outdir).unwrap();
2022-02-03 22:50:39 +03:00
}
2020-05-21 15:37:10 +03:00
}