-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
31 lines (25 loc) · 955 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
30
31
#[macro_use]
extern crate clap;
extern crate clap_generate;
use std::{env, fs, path::PathBuf};
#[path="src/cli.rs"]
mod cli;
fn main() {
let outdir = env::current_dir().expect("where am i").join("etc");
fs::create_dir_all(&outdir).unwrap();
use clap::IntoApp;
let app = cli::Head::into_app();
use clap_generate::gen_manuals;
for man in gen_manuals(&app) {
let name = "clap-man-demo.1"; // FIXME: Extract this from man!
let path = PathBuf::from(&outdir).join(name);
let mut out = fs::File::create(&path).unwrap();
use std::io::Write;
out.write_all(man.render().as_bytes()).unwrap();
eprintln!("Wrote man page to {:?}", path);
}
// FIXME: Shell is private!
// use clap_generate::{gen_completions, Shell};
// gen_completions(&mut app, "clap-man-demo", Shell::Bash, outdir.clone());
// gen_completions(&mut app, "clap-man-demo", Shell::Fish, outdir.clone());
}