zoxide/build.rs

35 lines
1.1 KiB
Rust
Raw Normal View History

2023-06-10 19:37:07 +00:00
#[path = "src/cmd/cmd.rs"]
mod cmd;
2021-09-13 08:01:58 +00:00
use std::{env, io};
2020-10-18 09:22:13 +00:00
2023-06-10 19:37:07 +00:00
use clap::CommandFactory;
use clap_complete::shells::{Bash, Elvish, Fish, PowerShell, Zsh};
use clap_complete_fig::Fig;
use cmd::Cmd;
2023-06-10 19:37:07 +00:00
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 08:29:24 +00:00
println!("cargo:rerun-if-changed=src/");
println!("cargo:rerun-if-changed=templates/");
println!("cargo:rerun-if-changed=tests/");
2023-06-10 19:37:07 +00:00
generate_completions()
}
2021-08-15 11:56:56 +00:00
fn generate_completions() -> io::Result<()> {
2023-06-10 19:37:07 +00:00
const BIN_NAME: &str = env!("CARGO_PKG_NAME");
const OUT_DIR: &str = "contrib/completions";
2022-02-16 22:46:45 +00:00
let cmd = &mut Cmd::command();
2021-05-03 21:12:43 +00:00
2023-06-10 19:37:07 +00:00
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 11:56:56 +00:00
Ok(())
2021-05-03 21:12:43 +00:00
}