diff options
author | Canop <cano.petrole@gmail.com> | 2020-01-12 16:41:14 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-01-12 16:41:14 +0100 |
commit | 16a9cba1910b6d1615e80d70fcad1c0c5cef8be6 (patch) | |
tree | a7995b0137bf2565b64f16a9f7b0eee11335704a /build.rs | |
parent | 48dc89a1837a13ed0c81aba6b752e449d529728a (diff) |
generate shell completion scripts on build
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..09f1b1f --- /dev/null +++ b/build.rs @@ -0,0 +1,25 @@ +// This file is executed during broot compilation. +// It build shell completion scripts. + +use { + clap::Shell, + std::{ + env, + str::FromStr, + }, +}; + +include!("src/clap.rs"); + +fn main() { + // out_dir should be defined, see + // https://doc.rust-lang.org/cargo/reference/environment-variables.html + let out_dir = env::var_os("OUT_DIR").expect("out dir not set"); + let mut app = clap_app(); + for variant in &Shell::variants() { + let variant = Shell::from_str(variant).unwrap(); + app.gen_completions("broot", variant, &out_dir); + app.gen_completions("br", variant, &out_dir); + } + println!("completion scripts generated in {:?}", out_dir); +} |