feat: add build time completion generation

This commit is contained in:
2026-02-28 23:04:51 +01:00
parent 1618e00383
commit d2635e692e
3 changed files with 45 additions and 0 deletions

28
build.rs Normal file
View File

@@ -0,0 +1,28 @@
#[allow(dead_code)]
#[path = "src/model.rs"]
mod model;
include!("src/cli.rs");
use clap::{CommandFactory, ValueEnum};
use clap_complete::{generate_to, Shell};
use std::{env, io::Error};
fn main() -> Result<(), Error> {
let outdir = env::var_os("SHELL_COMPLETIONS_DIR")
.or_else(|| env::var_os("OUT_DIR"));
let Some(outdir) = outdir else {
return Ok(());
};
let mut cmd = Cli::command();
for shell in Shell::value_variants() {
let path = generate_to(*shell, &mut cmd, "todo", &outdir)?;
println!("cargo:warning=completion file is generated: {path:?}");
}
Ok(())
}