diff --git a/Cargo.lock b/Cargo.lock index 332f122..c56204d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,6 +88,7 @@ dependencies = [ "avt", "axum", "clap", + "clap_complete", "clap_mangen", "config", "futures-util", @@ -318,6 +319,15 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_complete" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e" +dependencies = [ + "clap", +] + [[package]] name = "clap_derive" version = "4.4.7" diff --git a/Cargo.toml b/Cargo.toml index b1a9e19..5597a2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ tokio-util = "0.7.10" [build-dependencies] clap = { version = "4.4.7", features = ["derive"] } +clap_complete = "4.5.2" clap_mangen = "0.2.20" url = "2.5.0" diff --git a/build.rs b/build.rs index b1a923c..d9c2528 100644 --- a/build.rs +++ b/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(()) }