summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-02-26 00:02:17 +0100
committerNora <nora.widdecke@tu-bs.de>2019-02-26 00:02:17 +0100
commitd5f228564451f13db48aa0a4d907b489d52fb28c (patch)
treefec5bfef98e6b1bc82b3f95091b1f5b3688f4e05
parent772d5e314c8b3523a85cd07b427b4f458580f232 (diff)
create shell completions for release build
-rw-r--r--Cargo.toml5
-rw-r--r--build.rs23
2 files changed, 28 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1278063..0f8a511 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,6 +3,7 @@ name = "khaleesi"
version = "0.1.0"
authors = ["Nora <nora.widdecke@tu-bs.de>"]
edition = "2018"
+build = "build.rs"
[dependencies]
libc = "0.2.43"
@@ -32,3 +33,7 @@ assert_fs = "0.11.3"
predicates = "1.0"
maplit = "1.0.1"
pretty_assertions = "0.6.1"
+
+[build-dependencies]
+clap = "2.32.0"
+structopt = "0.2.14"
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..7ac375c
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,23 @@
+#[macro_use]
+extern crate clap;
+extern crate structopt;
+
+use std::env;
+use structopt::clap::Shell;
+
+include!("src/cli.rs");
+
+fn main() {
+ if env::var_os("PROFILE") == Some("release".into()) {
+ let outdir = match env::var_os("OUT_DIR") {
+ None => return,
+ Some(outdir) => outdir,
+ };
+ let mut app = CommandLine::clap();
+ let binary_name = "khaleesi";
+ app.gen_completions(binary_name, Shell::Bash, &outdir);
+ app.gen_completions(binary_name, Shell::Zsh, &outdir);
+ app.gen_completions(binary_name, Shell::Fish, &outdir);
+ app.gen_completions(binary_name, Shell::Elvish, &outdir);
+ }
+}