feat: compile time completion generation

Removed `completion` command in favor of compile time completion
generation. This tool will only be build from source for the foreseeable
future so this makes sense for now.
This commit is contained in:
2023-08-09 14:45:07 +02:00
parent e061d6dc6c
commit 2754a3bb30
4 changed files with 28 additions and 17 deletions

22
build.rs Normal file
View File

@@ -0,0 +1,22 @@
use clap::{CommandFactory, ValueEnum};
use clap_complete::{generate_to, Shell};
use std::{env, io::Error};
include!("src/cli/mod.rs");
fn main() -> Result<(), Error> {
let outdir = match env::var_os("OUT_DIR") {
None => return Ok(()),
Some(outdir) => outdir,
};
let mut cmd = ahab::Ahab::command();
for shell in Shell::value_variants() {
let path = generate_to(*shell, &mut cmd, "ahab", &outdir)?;
println!("cargo:warning=completion file is generated: {path:?}");
}
Ok(())
}