zoxide/build.rs

35 lines
1.1 KiB
Rust
Raw Normal View History

2023-06-11 01:07:07 +05:30
#[path = "src/cmd/cmd.rs"]
mod cmd;
2021-09-13 13:31:58 +05:30
use std::{env, io};
2020-10-18 14:52:13 +05:30
2023-06-11 01:07:07 +05:30
use clap::CommandFactory;
use clap_complete::shells::{Bash, Elvish, Fish, PowerShell, Zsh};
use clap_complete_fig::Fig;
use cmd::Cmd;
2023-06-11 01:07:07 +05:30
fn main() -> io::Result<()> {
// Since we are generating completions in the package directory, we need to
// set this so that Cargo doesn't rebuild every time.
println!("cargo:rerun-if-changed=build.rs");
2022-09-02 13:59:24 +05:30
println!("cargo:rerun-if-changed=src/");
println!("cargo:rerun-if-changed=templates/");
println!("cargo:rerun-if-changed=tests/");
2023-06-11 01:07:07 +05:30
generate_completions()
}
2021-08-15 17:26:56 +05:30
fn generate_completions() -> io::Result<()> {
2023-06-11 01:07:07 +05:30
const BIN_NAME: &str = env!("CARGO_PKG_NAME");
const OUT_DIR: &str = "contrib/completions";
2022-02-17 04:16:45 +05:30
let cmd = &mut Cmd::command();
2021-05-04 02:42:43 +05:30
2023-06-11 01:07:07 +05:30
clap_complete::generate_to(Bash, cmd, BIN_NAME, OUT_DIR)?;
clap_complete::generate_to(Elvish, cmd, BIN_NAME, OUT_DIR)?;
clap_complete::generate_to(Fig, cmd, BIN_NAME, OUT_DIR)?;
clap_complete::generate_to(Fish, cmd, BIN_NAME, OUT_DIR)?;
clap_complete::generate_to(PowerShell, cmd, BIN_NAME, OUT_DIR)?;
clap_complete::generate_to(Zsh, cmd, BIN_NAME, OUT_DIR)?;
2021-08-15 17:26:56 +05:30
Ok(())
2021-05-04 02:42:43 +05:30
}