on master help sign in
Add --diagnostic option to bat
ebb97e9sharkdp
Cargo.lock+59−2
@@ -98,6 +98,7 @@ dependencies = [
98 "ansi_term 0.12.1",
98 "ansi_term 0.12.1",
99 "assert_cmd",
99 "assert_cmd",
100 "atty",
100 "atty",
101+ "bugreport",
101 "clap",
102 "clap",
102 "clircle",
103 "clircle",
103 "console",
104 "console",
@@ -193,6 +194,16 @@ dependencies = [
193 "memchr",
194 "memchr",
194]
195]
195
196
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+
196[[package]]
207[[package]]
197name = "byte-tools"
208name = "byte-tools"
198version = "0.3.1"
209version = "0.3.1"
@@ -1070,6 +1081,16 @@ version = "1.0.0"
1070source = "registry+https://github.com/rust-lang/crates.io-index"
1081source = "registry+https://github.com/rust-lang/crates.io-index"
1071checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
1082checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
1072
1083
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+
1073[[package]]
1094[[package]]
1074name = "std_prelude"
1095name = "std_prelude"
1075version = "0.2.12"
1096version = "0.2.12"
@@ -1084,9 +1105,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
1084
1105
1085[[package]]
1106[[package]]
1086name = "syn"
1107name = "syn"
1087−version = "1.0.42"
1108+version = "1.0.55"
1088source = "registry+https://github.com/rust-lang/crates.io-index"
1109source = "registry+https://github.com/rust-lang/crates.io-index"
1089−checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228"
1110+checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a"
1090dependencies = [
1111dependencies = [
1091 "proc-macro2",
1112 "proc-macro2",
1092 "quote",
1113 "quote",
@@ -1116,6 +1137,16 @@ dependencies = [
1116 "yaml-rust",
1137 "yaml-rust",
1117]
1138]
1118
1139
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+
1119[[package]]
1150[[package]]
1120name = "tempdir"
1151name = "tempdir"
1121version = "0.3.7"
1152version = "0.3.7"
@@ -1156,6 +1187,26 @@ dependencies = [
1156 "unicode-width",
1187 "unicode-width",
1157]
1188]
1158
1189
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+
1159[[package]]
1210[[package]]
1160name = "thread_local"
1211name = "thread_local"
1161version = "1.0.1"
1212version = "1.0.1"
@@ -1219,6 +1270,12 @@ version = "0.2.1"
1219source = "registry+https://github.com/rust-lang/crates.io-index"
1270source = "registry+https://github.com/rust-lang/crates.io-index"
1220checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
1271checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
1221
1272
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+
1222[[package]]
1279[[package]]
1223name = "url"
1280name = "url"
1224version = "2.1.1"
1281version = "2.1.1"
Cargo.toml+1
@@ -51,6 +51,7 @@ serde_yaml = "0.8"
51semver = "0.11"
51semver = "0.11"
52path_abs = { version = "0.5", default-features = false }
52path_abs = { version = "0.5", default-features = false }
53clircle = "0.2.0"
53clircle = "0.2.0"
54+bugreport = "0.1"
54
55
55[dependencies.git2]
56[dependencies.git2]
56version = "0.13"
57version = "0.13"
src/bin/bat/clap_app.rs+6
@@ -477,6 +477,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
477 .hidden(true)
477 .hidden(true)
478 .help("Show bat's cache directory."),
478 .help("Show bat's cache directory."),
479 )
479 )
480+ .arg(
481+ Arg::with_name("diagnostic")
482+ .long("diagnostic")
483+ .hidden_short_help(true)
484+ .help("Show diagnostic information for bug reports.")
485+ )
480 .help_message("Print this help message.")
486 .help_message("Print this help message.")
481 .version_message("Show version information.");
487 .version_message("Show version information.");
482
488
src/bin/bat/main.rs+22−2
@@ -35,8 +35,7 @@ use bat::{
35 error::*,
35 error::*,
36 input::Input,
36 input::Input,
37 style::{StyleComponent, StyleComponents},
37 style::{StyleComponent, StyleComponents},
38− MappingTarget,
38+ MappingTarget, PagingMode,
39− PagingMode,
40};
39};
41
40
42const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
41const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
@@ -228,6 +227,27 @@ fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
228fn run() -> Result<bool> {
227fn run() -> Result<bool> {
229 let app = App::new()?;
228 let app = App::new()?;
230
229
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+
231 match app.matches.subcommand() {
251 match app.matches.subcommand() {
232 ("cache", Some(cache_matches)) => {
252 ("cache", Some(cache_matches)) => {
233 // If there is a file named 'cache' in the current working directory,
253 // If there is a file named 'cache' in the current working directory,