diff options
author | davideGiovannini <davide.giovannini@studenti.unitn.it> | 2018-10-03 09:39:30 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2018-10-03 09:39:30 +0200 |
commit | 0d7196861523ca14a1df58f7fbf9a75c34723175 (patch) | |
tree | 083967c8307d644734c63db0bcb088c0daae30e8 /build.rs | |
parent | 80da0dc6194d94dbbc87185283d4e299b8101dfd (diff) |
Generate shell completions with clap during build (#327)
* Generate shell completions with clap during build
* Updated ci release script, added SHELL_COMPLETIONS_DIR override to build.rs and fixed dependency version
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..78085579 --- /dev/null +++ b/build.rs @@ -0,0 +1,26 @@ +#[macro_use] +extern crate clap; + +use clap::Shell; +use std::fs; + +include!("src/clap_app.rs"); + +const BIN_NAME: &str = "bat"; + +fn main() { + let outdir = std::env::var_os("SHELL_COMPLETIONS_DIR").or(std::env::var_os("OUT_DIR")); + + let outdir = match outdir { + None => return, + Some(outdir) => outdir, + }; + + fs::create_dir_all(&outdir).unwrap(); + + let mut app = build_app(true); + app.gen_completions(BIN_NAME, Shell::Bash, &outdir); + app.gen_completions(BIN_NAME, Shell::Fish, &outdir); + app.gen_completions(BIN_NAME, Shell::Zsh, &outdir); + app.gen_completions(BIN_NAME, Shell::PowerShell, &outdir); +} |