-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
33 lines (26 loc) · 822 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
#[path = "src/bin/cnc/cli.rs"]
mod cnc;
#[allow(dead_code)]
#[path = "src/bin/conceal/cli.rs"]
mod conceal;
use clap::{Command, CommandFactory};
use clap_complete::generate_to;
use clap_complete::Shell::{Bash, Fish, Zsh};
use clap_complete_nushell::Nushell;
use std::fs;
use std::io;
use std::path::PathBuf;
fn main() -> io::Result<()> {
generate_completions(&mut cnc::Cli::command(), "cnc")?;
generate_completions(&mut conceal::Cli::command(), "conceal")?;
Ok(())
}
fn generate_completions(cmd: &mut Command, name: &str) -> io::Result<()> {
let dir = &PathBuf::from("completions").join(name);
fs::create_dir_all(dir)?;
generate_to(Zsh, cmd, name, dir)?;
generate_to(Bash, cmd, name, dir)?;
generate_to(Fish, cmd, name, dir)?;
generate_to(Nushell, cmd, name, dir)?;
Ok(())
}