lir/build.rs
Christina Sørensen 3b81342f1d
build(flake): introduce flake for dev/package
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2024-02-05 07:22:37 +01:00

40 lines
968 B
Rust

// SPDX-FileCopyrightText: 2023 Christina Sørensen
// SPDX-FileContributor: Christina Sørensen
//
// SPDX-License-Identifier: AGPL-3.0-only
use clap::ValueEnum;
use clap_complete::{generate_to, Shell};
use clap_mangen::Man;
use std::env;
use std::fs::File;
use std::io::Error;
use std::path::PathBuf;
include!("src/cli/command.rs");
fn main() -> Result<(), Error> {
let real_outdir = match env::var_os("OUT_DIR") {
None => return Ok(()),
Some(outdir) => outdir,
};
let outdir = match env::var_os("MAN_OUT") {
None => real_outdir,
Some(outdir) => outdir,
};
let mut cmd = build_cli();
for &shell in Shell::value_variants() {
generate_to(shell, &mut cmd, "lir", &outdir)?;
}
let file = PathBuf::from(&outdir).join("lir.1");
let mut file = File::create(file)?;
Man::new(cmd).render(&mut file)?;
println!("cargo:warning=completion file is generated: {outdir:?}");
Ok(())
}