0
0
mirror of https://github.com/TeFiLeDo/tree-owners.git synced 2024-11-14 00:36:22 +01:00
tree-owners/build.rs

28 lines
827 B
Rust
Raw Normal View History

2023-09-24 12:23:20 +02:00
use std::{env, fs::create_dir};
use anyhow::{Context, Result};
use clap::CommandFactory;
use clap_complete::{
generate_to,
shells::{Bash, Fish, Zsh},
};
include!("src/cli.rs");
fn main() -> Result<()> {
let out = if env::var("CI").map(|ci| ci == "true").unwrap_or_default() {
2023-09-24 14:58:17 +02:00
create_dir("../ci-out").context("failed to create CI output directory")?;
"../ci-out".to_string()
2023-09-24 12:23:20 +02:00
} else {
env::var("OUT_DIR").context("OUT_DIR not set")?
};
println!("cargo:rerun-if-changed=src/cli.rs");
let mut cli = <Args as CommandFactory>::command();
let _ = generate_to(Fish, &mut cli, env!("CARGO_PKG_NAME"), out.clone());
let _ = generate_to(Bash, &mut cli, env!("CARGO_PKG_NAME"), out.clone());
let _ = generate_to(Zsh, &mut cli, env!("CARGO_PKG_NAME"), out);
Ok(())
}