diff options
author | sharkdp <davidpeter@web.de> | 2020-12-31 18:17:15 +0100 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2021-01-06 22:53:51 +0100 |
commit | ebb97e94a9f3936e7db23c211f9dba779b0daa89 (patch) | |
tree | 19a4bdbf56bd5ed128a6adfaf4772e91fced8c21 /src | |
parent | 5e1f9fadf4d9a45c39e41ebc0deb567fbc0427fd (diff) |
Add --diagnostic option to bat
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/bat/clap_app.rs | 6 | ||||
-rw-r--r-- | src/bin/bat/main.rs | 24 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 4e642760..b2ebb6f7 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -477,6 +477,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .hidden(true) .help("Show bat's cache directory."), ) + .arg( + Arg::with_name("diagnostic") + .long("diagnostic") + .hidden_short_help(true) + .help("Show diagnostic information for bug reports.") + ) .help_message("Print this help message.") .version_message("Show version information."); diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index af8ca787..cd164aba 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -35,8 +35,7 @@ use bat::{ error::*, input::Input, style::{StyleComponent, StyleComponents}, - MappingTarget, - PagingMode, + MappingTarget, PagingMode, }; const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs"); @@ -228,6 +227,27 @@ fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> { fn run() -> Result<bool> { let app = App::new()?; + if app.matches.is_present("diagnostic") { + use bugreport::{bugreport, collectors::*}; + + bugreport!() + .info(SoftwareVersion::default()) + .info(OperatingSystem::default()) + .info(CommandLine::default()) + .info(EnvironmentVariables::list(&[ + "SHELL", + "PAGER", + "BAT_PAGER", + "BAT_CONFIG_PATH", + "BAT_STYLE", + "BAT_THEME", + "BAT_TABS", + ])) + .print_markdown(); + + return Ok(true); + } + match app.matches.subcommand() { ("cache", Some(cache_matches)) => { // If there is a file named 'cache' in the current working directory, |