-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
53 lines (42 loc) · 2 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
// This file is part of peertube-viewer-rs.
//
// peertube-viewer-rs is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
//
// peertube-viewer-rs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along with peertube-viewer-rs. If not, see <https://www.gnu.org/licenses/>.
extern crate clap;
use clap_complete::{
generate_to,
shells::{Bash, Elvish, Fish, PowerShell, Zsh},
};
use std::{
env,
fs::{create_dir, read_to_string, write},
};
include!("src/cli/clap_app.rs");
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=peertube-viewer-rs.1.in");
println!("cargo:rerun-if-changed=src/cli/clap_app.rs");
let manpage = read_to_string("peertube-viewer-rs.1.in").unwrap();
let manpage_out = manpage.replace("@version@", env!("CARGO_PKG_VERSION"));
write("peertube-viewer-rs.1", manpage_out).unwrap();
create_dir("./completions").unwrap_or(());
let mut app = gen_app();
generate_to(Bash, &mut app, env!("CARGO_PKG_NAME"), "./completions")
.expect("Failed to generate completions");
generate_to(Elvish, &mut app, env!("CARGO_PKG_NAME"), "./completions")
.expect("Failed to generate completions");
generate_to(Fish, &mut app, env!("CARGO_PKG_NAME"), "./completions")
.expect("Failed to generate completions");
generate_to(
PowerShell,
&mut app,
env!("CARGO_PKG_NAME"),
"./completions",
)
.expect("Failed to generate completions");
generate_to(Zsh, &mut app, env!("CARGO_PKG_NAME"), "./completions")
.expect("Failed to generate completions");
}