aboutsummaryrefslogtreecommitdiffstats
path: root/build.rs
diff options
context:
space:
mode:
authorHenil Dedania <dedaniahenil@gmail.com>2021-01-07 15:14:28 +0530
committerGitHub <noreply@github.com>2021-01-07 15:14:28 +0530
commit0994c8abcd0f522362532ecbaa4900915d1c42f9 (patch)
tree297b3e1f1b6a7b4fd70aa57d76720df148f625c2 /build.rs
parentMerge pull request #131 from mosaic-org/mosaic#130 (diff)
downloadsl0ppij-0994c8abcd0f522362532ecbaa4900915d1c42f9.tar.gz
sl0ppij-0994c8abcd0f522362532ecbaa4900915d1c42f9.tar.xz
sl0ppij-0994c8abcd0f522362532ecbaa4900915d1c42f9.zip
feat(completions): Add shell completions files (#128)
* Add shell completions and output files to `assets/completions` * Rename files and struct name * Update tests to take into account new changes
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/build.rs b/build.rs
new file mode 100644
index 00000000..58430643
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,24 @@
+use std::fs;
+use structopt::clap::Shell;
+
+include!("src/cli.rs");
+
+const BIN_NAME: &str = "mosaic";
+
+fn main() {
+ let mut clap_app = CliArgs::clap();
+ println!("cargo:rerun-if-changed=src/app.rs");
+ let mut out_dir = std::env::var_os("CARGO_MANIFEST_DIR")
+ .unwrap()
+ .to_os_string();
+ out_dir.push("/assets/completions");
+
+ println!(
+ "Completion files will to added to this location: {:?}",
+ out_dir
+ );
+ fs::create_dir_all(&out_dir).unwrap();
+ clap_app.gen_completions(BIN_NAME, Shell::Bash, &out_dir);
+ clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir);
+ clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir);
+}