on master help sign in
Add --diagnostic option to bat
commitebb97e94a9f3936e7db23c211f9dba779b0daa89 authorsharkdp <davidpeter@web.de> dateThu 31 Dec 2020, 18:17 (6 years ago) parent5e1f9fa
4 files changed+88−4
Cargo.lock+59−2 Cargo.toml+1 src/bin/bat/clap_app.rs+6 src/bin/bat/main.rs+22−2
Cargo.lock+59−2
@@ -98,6 +98,7 @@ dependencies = [
9898 "ansi_term 0.12.1",
9999 "assert_cmd",
100100 "atty",
101+ "bugreport",
101102 "clap",
102103 "clircle",
103104 "console",
@@ -193,6 +194,16 @@ dependencies = [
193194 "memchr",
194195]
195196
197+[[package]]
198+name = "bugreport"
199+version = "0.1.0"
200+source = "registry+https://github.com/rust-lang/crates.io-index"
201+checksum = "824268bc0fcb3b94da597b81fa9dd52175cfde5522f4892a0cff3932802ff805"
202+dependencies = [
203+ "snailquote",
204+ "sys-info",
205+]
206+
196207[[package]]
197208name = "byte-tools"
198209version = "0.3.1"
@@ -1070,6 +1081,16 @@ version = "1.0.0"
10701081source = "registry+https://github.com/rust-lang/crates.io-index"
10711082checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
10721083
1084+[[package]]
1085+name = "snailquote"
1086+version = "0.3.0"
1087+source = "registry+https://github.com/rust-lang/crates.io-index"
1088+checksum = "f34b729d802f52194598858ac852c3fb3b33f6e026cd03195072ccb7bf3fc810"
1089+dependencies = [
1090+ "thiserror",
1091+ "unicode_categories",
1092+]
1093+
10731094[[package]]
10741095name = "std_prelude"
10751096version = "0.2.12"
@@ -1084,9 +1105,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
10841105
10851106[[package]]
10861107name = "syn"
1087−version = "1.0.42"
1108+version = "1.0.55"
10881109source = "registry+https://github.com/rust-lang/crates.io-index"
1089−checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228"
1110+checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a"
10901111dependencies = [
10911112 "proc-macro2",
10921113 "quote",
@@ -1116,6 +1137,16 @@ dependencies = [
11161137 "yaml-rust",
11171138]
11181139
1140+[[package]]
1141+name = "sys-info"
1142+version = "0.7.0"
1143+source = "registry+https://github.com/rust-lang/crates.io-index"
1144+checksum = "e5cfbd84f86389198ade41b439f72a5b1b3a8ba728e61cd589e1720d0df44c39"
1145+dependencies = [
1146+ "cc",
1147+ "libc",
1148+]
1149+
11191150[[package]]
11201151name = "tempdir"
11211152version = "0.3.7"
@@ -1156,6 +1187,26 @@ dependencies = [
11561187 "unicode-width",
11571188]
11581189
1190+[[package]]
1191+name = "thiserror"
1192+version = "1.0.22"
1193+source = "registry+https://github.com/rust-lang/crates.io-index"
1194+checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e"
1195+dependencies = [
1196+ "thiserror-impl",
1197+]
1198+
1199+[[package]]
1200+name = "thiserror-impl"
1201+version = "1.0.22"
1202+source = "registry+https://github.com/rust-lang/crates.io-index"
1203+checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56"
1204+dependencies = [
1205+ "proc-macro2",
1206+ "quote",
1207+ "syn",
1208+]
1209+
11591210[[package]]
11601211name = "thread_local"
11611212version = "1.0.1"
@@ -1219,6 +1270,12 @@ version = "0.2.1"
12191270source = "registry+https://github.com/rust-lang/crates.io-index"
12201271checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
12211272
1273+[[package]]
1274+name = "unicode_categories"
1275+version = "0.1.1"
1276+source = "registry+https://github.com/rust-lang/crates.io-index"
1277+checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
1278+
12221279[[package]]
12231280name = "url"
12241281version = "2.1.1"
Cargo.toml+1
@@ -51,6 +51,7 @@ serde_yaml = "0.8"
5151semver = "0.11"
5252path_abs = { version = "0.5", default-features = false }
5353clircle = "0.2.0"
54+bugreport = "0.1"
5455
5556[dependencies.git2]
5657version = "0.13"
src/bin/bat/clap_app.rs+6
@@ -477,6 +477,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
477477 .hidden(true)
478478 .help("Show bat's cache directory."),
479479 )
480+ .arg(
481+ Arg::with_name("diagnostic")
482+ .long("diagnostic")
483+ .hidden_short_help(true)
484+ .help("Show diagnostic information for bug reports.")
485+ )
480486 .help_message("Print this help message.")
481487 .version_message("Show version information.");
482488
src/bin/bat/main.rs+22−2
@@ -35,8 +35,7 @@ use bat::{
3535 error::*,
3636 input::Input,
3737 style::{StyleComponent, StyleComponents},
38− MappingTarget,
39− PagingMode,
38+ MappingTarget, PagingMode,
4039};
4140
4241const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
@@ -228,6 +227,27 @@ fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
228227fn run() -> Result<bool> {
229228 let app = App::new()?;
230229
230+ if app.matches.is_present("diagnostic") {
231+ use bugreport::{bugreport, collectors::*};
232+
233+ bugreport!()
234+ .info(SoftwareVersion::default())
235+ .info(OperatingSystem::default())
236+ .info(CommandLine::default())
237+ .info(EnvironmentVariables::list(&[
238+ "SHELL",
239+ "PAGER",
240+ "BAT_PAGER",
241+ "BAT_CONFIG_PATH",
242+ "BAT_STYLE",
243+ "BAT_THEME",
244+ "BAT_TABS",
245+ ]))
246+ .print_markdown();
247+
248+ return Ok(true);
249+ }
250+
231251 match app.matches.subcommand() {
232252 ("cache", Some(cache_matches)) => {
233253 // If there is a file named 'cache' in the current working directory,