24 lines
1.0 KiB
Rust
24 lines
1.0 KiB
Rust
//! Generates shell completions and a man page for `cbd` from its top-level
|
|
//! clap command (architecture/cli.md D7). Written into `OUT_DIR` every build,
|
|
//! and additionally into `$CBD_ASSET_DIR` when set. `cbd-cli` is a
|
|
//! default-features (clap-only) build-dependency, so this never pulls tonic
|
|
//! into ordinary builds.
|
|
|
|
use std::path::Path;
|
|
|
|
fn main() {
|
|
use clap::CommandFactory;
|
|
println!("cargo:rerun-if-env-changed=CBD_ASSET_DIR");
|
|
let bin = "cbd";
|
|
let command = cbd_cli::CbdCli::command();
|
|
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is set for build scripts");
|
|
if let Err(err) = cbd_cli::generate_assets(command.clone(), bin, Path::new(&out_dir)) {
|
|
println!("cargo:warning=cannot generate CLI assets into OUT_DIR: {err}");
|
|
}
|
|
if let Some(asset_dir) = std::env::var_os("CBD_ASSET_DIR") {
|
|
if let Err(err) = cbd_cli::generate_assets(command, bin, Path::new(&asset_dir)) {
|
|
println!("cargo:warning=cannot generate CLI assets into CBD_ASSET_DIR: {err}");
|
|
}
|
|
}
|
|
}
|