-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
40 lines (31 loc) · 970 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 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, "rime", &outdir)?;
}
let file = PathBuf::from(&outdir).join("rime.1");
let mut file = File::create(file)?;
Man::new(cmd).render(&mut file)?;
println!("cargo:warning=completion file is generated: {outdir:?}");
Ok(())
}