mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-15 19:28:00 +01:00
Generate shell auto-completion files at build time
This commit is contained in:
11
build.rs
11
build.rs
@@ -1,4 +1,6 @@
|
||||
use clap::CommandFactory;
|
||||
use clap::ValueEnum;
|
||||
use clap_complete::{generate_to, Shell};
|
||||
use clap_mangen::Man;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
@@ -11,9 +13,14 @@ mod cli {
|
||||
|
||||
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 cmd = cli::Cli::command();
|
||||
|
||||
let man = Man::new(cmd.clone());
|
||||
man.render(&mut File::create(out_dir.join("asciinema.1"))?)?;
|
||||
|
||||
for shell in Shell::value_variants() {
|
||||
generate_to(*shell, &mut cmd, "asciinema", &out_dir).unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user