From cc183fccca73df619c78dd0ca2567ac547c56ad2 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 8 Sep 2024 23:39:48 -0400 Subject: feat: initial commit --- build.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 build.rs (limited to 'build.rs') diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..4d84adc --- /dev/null +++ b/build.rs @@ -0,0 +1,25 @@ +use std::io::Error; + +use clap::{CommandFactory, ValueEnum}; +use clap_complete::{generate_to, Shell}; + +include!("src/cli.rs"); + +fn main() -> Result<(), Error> { + let out_dir = if let Some(completion_dir) = option_env!("COMPLETION_DIR") { + std::fs::create_dir_all(completion_dir)?; + completion_dir.to_string() + } else if let Ok(out_dir) = std::env::var("OUT_DIR") { + out_dir + } else { + println!("cargo:warning=Unable to resolve `COMPLETION_DIR` or `OUT_DIR` in environment. Completions will not be built"); + return Ok(()); + }; + + let mut command = Cli::command(); + for &shell in Shell::value_variants() { + generate_to(shell, &mut command, env!("CARGO_PKG_NAME"), &out_dir)?; + } + + Ok(()) +} -- cgit v1.2.3