diff --git a/Cargo.lock b/Cargo.lock index 9d34c3c4..b483ef2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,6 +98,7 @@ dependencies = [ "ansi_term 0.12.1", "assert_cmd", "atty", + "bugreport", "clap", "clircle", "console", @@ -193,6 +194,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "bugreport" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824268bc0fcb3b94da597b81fa9dd52175cfde5522f4892a0cff3932802ff805" +dependencies = [ + "snailquote", + "sys-info", +] + [[package]] name = "byte-tools" version = "0.3.1" @@ -1070,6 +1081,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" +[[package]] +name = "snailquote" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f34b729d802f52194598858ac852c3fb3b33f6e026cd03195072ccb7bf3fc810" +dependencies = [ + "thiserror", + "unicode_categories", +] + [[package]] name = "std_prelude" version = "0.2.12" @@ -1084,9 +1105,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.42" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" +checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a" dependencies = [ "proc-macro2", "quote", @@ -1116,6 +1137,16 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "sys-info" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5cfbd84f86389198ade41b439f72a5b1b3a8ba728e61cd589e1720d0df44c39" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "tempdir" version = "0.3.7" @@ -1156,6 +1187,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -1219,6 +1270,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "url" version = "2.1.1" diff --git a/Cargo.toml b/Cargo.toml index 212db77a..9538f515 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ serde_yaml = "0.8" semver = "0.11" path_abs = { version = "0.5", default-features = false } clircle = "0.2.0" +bugreport = "0.1" [dependencies.git2] version = "0.13" 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, config: &Config) -> Result { fn run() -> Result { 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,