1// TODO: Re-enable generation of shell completion files (below) when clap 3 is out.
2// For more details, see https://github.com/sharkdp/bat/issues/372
5extern crate lazy_static;
11// Read environment variables.
13 pub static ref PROJECT_NAME: &'static str = option_env!("PROJECT_NAME").unwrap_or("bat");
14 pub static ref PROJECT_VERSION: &'static str = option_env!("CARGO_PKG_VERSION").unwrap();
15 pub static ref EXECUTABLE_NAME: &'static str = option_env!("PROJECT_EXECUTABLE")
16 .or(option_env!("PROJECT_NAME"))
20fn init_template() -> liquid::value::Object {
21 let mut globals = liquid::value::Object::new();
24 "PROJECT_NAME".into(),
25 liquid::value::Value::scalar(PROJECT_NAME.to_owned()),
29 "PROJECT_EXECUTABLE".into(),
30 liquid::value::Value::scalar(EXECUTABLE_NAME.to_owned()),
34 "PROJECT_VERSION".into(),
35 liquid::value::Value::scalar(PROJECT_VERSION.to_owned()),
41/// Generates a file from a liquid template.
43 variables: &liquid::value::Object,
46) -> Result<(), Box<dyn Error>> {
47 let template = liquid::ParserBuilder::with_liquid()
49 .parse(&fs::read_to_string(in_file)?)?;
51 fs::write(out_file, template.render(variables)?)?;
55fn main() -> Result<(), Box<dyn Error>> {
56 let variables = init_template();
58 template(&variables, "assets/manual/bat.1.in", "assets/manual/bat.1")?;
61 "assets/completions/bat.fish.in",
62 "assets/completions/bat.fish",
74// include!("src/clap_app.rs");
76// const BIN_NAME: &str = "bat";
79// let outdir = std::env::var_os("SHELL_COMPLETIONS_DIR").or(std::env::var_os("OUT_DIR"));
81// let outdir = match outdir {
83// Some(outdir) => outdir,
86// fs::create_dir_all(&outdir).unwrap();
88// let mut app = build_app(true);
89// app.gen_completions(BIN_NAME, Shell::Bash, &outdir);
90// app.gen_completions(BIN_NAME, Shell::Fish, &outdir);
91// app.gen_completions(BIN_NAME, Shell::Zsh, &outdir);
92// app.gen_completions(BIN_NAME, Shell::PowerShell, &outdir);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list