mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-02 03:12:25 +01:00
Generate shell completions with clap during build (#327)
* Generate shell completions with clap during build * Updated ci release script, added SHELL_COMPLETIONS_DIR override to build.rs and fixed dependency version
This commit is contained in:
committed by
David Peter
parent
80da0dc619
commit
0d71968615
26
build.rs
Normal file
26
build.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
|
||||
use clap::Shell;
|
||||
use std::fs;
|
||||
|
||||
include!("src/clap_app.rs");
|
||||
|
||||
const BIN_NAME: &str = "bat";
|
||||
|
||||
fn main() {
|
||||
let outdir = std::env::var_os("SHELL_COMPLETIONS_DIR").or(std::env::var_os("OUT_DIR"));
|
||||
|
||||
let outdir = match outdir {
|
||||
None => return,
|
||||
Some(outdir) => outdir,
|
||||
};
|
||||
|
||||
fs::create_dir_all(&outdir).unwrap();
|
||||
|
||||
let mut app = build_app(true);
|
||||
app.gen_completions(BIN_NAME, Shell::Bash, &outdir);
|
||||
app.gen_completions(BIN_NAME, Shell::Fish, &outdir);
|
||||
app.gen_completions(BIN_NAME, Shell::Zsh, &outdir);
|
||||
app.gen_completions(BIN_NAME, Shell::PowerShell, &outdir);
|
||||
}
|
Reference in New Issue
Block a user