Add --diagnostic option to bat

This commit is contained in:
sharkdp
2020-12-31 18:17:15 +01:00
committed by David Peter
parent 5e1f9fadf4
commit ebb97e94a9
4 changed files with 88 additions and 4 deletions

View File

@ -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.");

View File

@ -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,