1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-03 18:51:44 +00:00

Include shell completions in the executable

This commit is contained in:
einfachIrgendwer0815
2024-11-15 19:43:39 +01:00
parent f81d4dc321
commit dbe25ba5e6
6 changed files with 53 additions and 0 deletions
+14
View File
@@ -3,6 +3,8 @@
mod app;
mod assets;
mod clap_app;
#[cfg(feature = "application")]
mod completions;
mod config;
mod directories;
mod input;
@@ -347,6 +349,18 @@ fn run() -> Result<bool> {
return Ok(true);
}
#[cfg(feature = "application")]
if let Some(shell) = app.matches.get_one::<String>("completion") {
match shell.as_str() {
"bash" => println!("{}", completions::BASH_COMPLETION),
"fish" => println!("{}", completions::FISH_COMPLETION),
"ps1" => println!("{}", completions::PS1_COMPLETION),
"zsh" => println!("{}", completions::ZSH_COMPLETION),
_ => unreachable!("No completion for shell '{}' available.", shell),
}
return Ok(true);
}
match app.matches.subcommand() {
Some(("cache", cache_matches)) => {
// If there is a file named 'cache' in the current working directory,