-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.rs
87 lines (55 loc) · 2.1 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use clap::{CommandFactory, builder::styling::Style};
const HEADER_STYLE: Style = Style::new().bold().underline();
fn main() -> std::io::Result<()> {
let out_dir = std::path::PathBuf::from(
std::env::var_os("OUT_DIR")
.ok_or(std::io::ErrorKind::NotFound)
.unwrap(),
);
let cmd = nilla_cli_def::Cli::command().after_long_help(format!(
"
{HEADER_STYLE}Valid project sources{HEADER_STYLE:#}
path
Fetch a Nilla project from a file path. This follows the format:
path:<path>
git
Fetch a Nilla project from a Git repository. This follows the format:
git:<url>
Optionally, additional customization can be applied using query parameters:
git:<url>?rev=<rev>&ref=<ref>&submodules=true&dir=<dir>
github
Fetch a Nilla project from a GitHub repository. This follows the format:
github:<owner>/<repo>
Optionally, additional customization can be applied using query parameters:
github:<owner>/<repo>?rev=<rev>&dir=<dir>
gitlab
Fetch a Nilla project from a GitLab repository. This follows the format:
gitlab:<owner>/<repo>
Optionally, additional customization can be applied using query parameters:
gitlab:<owner>/<repo>?rev=<rev>&dir=<dir>
tarball
Fetch a Nilla project from a tarball. This follows the format:
tarball:<url>
The tarball source is also the default used when no other protocol matches. For
example, the following are equivalent:
tarball:http://example.com/project.tar.gz
http://example.com/project.tar.gz
"
));
let man = clap_mangen::Man::new(cmd.clone());
let mans = cmd
.get_subcommands()
.map(|sc| clap_mangen::Man::new(sc.clone()));
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(out_dir.join(man.get_filename()), buffer)?;
for man in mans {
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(
out_dir.join(format!("nilla-{}", man.get_filename())),
buffer,
)?;
}
Ok(())
}