-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
29 lines (25 loc) · 1022 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
use std::ffi::OsString;
use clap::Command;
use clap::CommandFactory;
use clap_complete::{Generator, Shell};
#[path = "src/cli.rs"]
mod cli;
fn print_completions<G: Generator>(gen: G, cmd: &mut Command, outdir: impl Into<OsString>) {
clap_complete::generate_to(gen, cmd, cmd.get_name().to_string(), outdir).unwrap();
}
fn generate_complete_scripts(cmd: &mut Command) {
print_completions(Shell::Zsh, cmd, "completion_scripts");
print_completions(Shell::Bash, cmd, "completion_scripts");
print_completions(Shell::Fish, cmd, "completion_scripts");
print_completions(Shell::PowerShell, cmd, "completion_scripts");
print_completions(Shell::Elvish, cmd, "completion_scripts");
}
fn main() {
println!("cargo:rerun-if-changed=src/cli.rs");
let mut cmd = cli::Cli::command();
generate_complete_scripts(&mut cmd);
let mut cmd = cli::StopCli::command();
generate_complete_scripts(&mut cmd);
let mut cmd = cli::GenerateGraphCli::command();
generate_complete_scripts(&mut cmd);
}