Files
ahab/build.rs
Matej Janežič 2754a3bb30 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.
2023-08-09 14:45:07 +02:00

23 lines
537 B
Rust

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(())
}