-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
36 lines (29 loc) · 805 Bytes
/
build.rs
File metadata and controls
36 lines (29 loc) · 805 Bytes
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
use std::fs;
use std::path::Path;
use clap::CommandFactory;
use clap_complete::Shell;
#[path = "src/cli.rs"]
mod cli;
fn main() {
let mut cmd = cli::Cli::command();
let name = "envex";
// -- Shell completions --
let comp_dir = Path::new("completions");
fs::create_dir_all(comp_dir).unwrap();
for shell in [
Shell::Bash,
Shell::Zsh,
Shell::Fish,
Shell::Elvish,
Shell::PowerShell,
] {
clap_complete::generate_to(shell, &mut cmd, name, comp_dir).unwrap();
}
// -- Man page --
let man_dir = Path::new("man");
fs::create_dir_all(man_dir).unwrap();
let man = clap_mangen::Man::new(cmd);
let mut buf = Vec::new();
man.render(&mut buf).unwrap();
fs::write(man_dir.join("envex.1"), buf).unwrap();
}