-
Notifications
You must be signed in to change notification settings - Fork 61
/
build.rs
53 lines (39 loc) · 1.11 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
// Importing from Ironbar modules brings in lots of things not used by the build script
// we can just globally suppress those.
#![allow(unused, dead_code)]
#[path = "src/cli.rs"]
mod cli;
#[path = "src/error.rs"]
mod error;
#[path = "src/ipc"]
mod ipc {
#[path = "commands.rs"]
mod commands;
#[path = "responses.rs"]
mod responses;
pub use commands::Command;
pub use responses::Response;
}
use clap::Command;
use clap::CommandFactory;
use clap_complete::generate_to;
use clap_complete::Shell::{Bash, Fish, Zsh};
use cli::Args;
use std::fs;
use std::path::PathBuf;
const NAME: &str = "ironbar";
fn generate_shell_completions(mut cmd: Command) -> std::io::Result<()> {
const MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
let comp_dir = PathBuf::from(MANIFEST_DIR).join("target/completions");
fs::create_dir_all(&comp_dir)?;
for shell in [Bash, Fish, Zsh] {
generate_to(shell, &mut cmd, NAME, &comp_dir)?;
}
Ok(())
}
fn main() -> std::io::Result<()> {
let mut cmd = Args::command();
cmd.set_bin_name(NAME);
generate_shell_completions(cmd)?;
Ok(())
}