diff options
| author | seth <[email protected]> | 2024-09-08 23:39:48 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-09-13 17:03:00 -0400 |
| commit | cc183fccca73df619c78dd0ca2567ac547c56ad2 (patch) | |
| tree | a06a87049cd90e877e626b8ff31e27a373df8f39 /build.rs | |
feat: initial commit
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..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(()) +} |
