Skye
f9df43f5e7
Output shell completions with `clap_complete`, moving the cli args types into a new file `cli_args.rs`, and add them to the nix package defined in the flake output. Update clap to 4.5.21. Various minor refactors in main.rs, including a removal of `itertools` as a dependency.
23 lines
536 B
Rust
23 lines
536 B
Rust
use std::{env, io};
|
|
|
|
use clap_complete::{generate_to, Shell};
|
|
use cli_args::Args;
|
|
use clap::{CommandFactory, ValueEnum};
|
|
|
|
mod cli_args {
|
|
include!("src/cli_args.rs");
|
|
}
|
|
|
|
fn main() -> io::Result<()> {
|
|
let Some(outdir) = env::var_os("OUT_DIR") else {
|
|
return Ok(());
|
|
};
|
|
let mut command = Args::command();
|
|
|
|
for shell in Shell::value_variants() {
|
|
generate_to(*shell, &mut command, "subtitle-merge", &outdir)?;
|
|
// println!("cargo:warning=completion file is generated: {path:?}");
|
|
}
|
|
Ok(())
|
|
}
|