2023-12-26 14:48:33 +03:00
|
|
|
#[path = "src/boot/args.rs"]
|
|
|
|
mod args;
|
2023-10-21 07:18:26 +03:00
|
|
|
|
2023-11-23 14:21:25 +03:00
|
|
|
use std::{env, error::Error, fs};
|
2023-10-21 07:18:26 +03:00
|
|
|
|
|
|
|
use clap::CommandFactory;
|
|
|
|
use clap_complete::{generate_to, Shell};
|
2023-11-23 14:21:25 +03:00
|
|
|
use vergen::EmitBuilder;
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
|
|
EmitBuilder::builder().build_date().git_sha(true).emit()?;
|
2023-10-21 07:18:26 +03:00
|
|
|
|
2023-10-22 11:34:20 +03:00
|
|
|
if env::var_os("YAZI_GEN_COMPLETIONS").is_none() {
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
2023-12-26 14:48:33 +03:00
|
|
|
let cmd = &mut args::Args::command();
|
2023-10-21 07:18:26 +03:00
|
|
|
let bin = "yazi";
|
|
|
|
let out = "completions";
|
|
|
|
|
|
|
|
fs::create_dir_all(out)?;
|
|
|
|
generate_to(Shell::Bash, cmd, bin, out)?;
|
|
|
|
generate_to(Shell::Fish, cmd, bin, out)?;
|
|
|
|
generate_to(Shell::Zsh, cmd, bin, out)?;
|
|
|
|
generate_to(Shell::Elvish, cmd, bin, out)?;
|
|
|
|
generate_to(Shell::PowerShell, cmd, bin, out)?;
|
|
|
|
generate_to(clap_complete_nushell::Nushell, cmd, bin, out)?;
|
|
|
|
generate_to(clap_complete_fig::Fig, cmd, bin, out)?;
|
2023-11-23 14:21:25 +03:00
|
|
|
|
2023-10-21 07:18:26 +03:00
|
|
|
Ok(())
|
|
|
|
}
|