Add build script, generate man page at build-time

This commit is contained in:
Marcin Kulik
2024-04-29 16:50:11 +02:00
parent b692339d50
commit 56884faca0
3 changed files with 42 additions and 0 deletions

20
build.rs Normal file
View File

@@ -0,0 +1,20 @@
use clap::CommandFactory;
use clap_mangen::Man;
use std::env;
use std::fs;
use std::io;
use std::path::PathBuf;
mod cli {
include!("src/cli.rs");
}
fn main() -> std::io::Result<()> {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").ok_or(io::ErrorKind::NotFound)?);
let cmd = cli::Cli::command();
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
fs::write(out_dir.join("asciinema.1"), buffer)
}