diff --git a/Cargo.lock b/Cargo.lock index 5c3abe9c..c5915ce0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,6 +103,17 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bugreport" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0e97e538864a7c95d33accbf64c8d354018ba3b6e032502fd0fe7259cf1aa3d" +dependencies = [ + "git-version", + "shell-escape", + "sys-info", +] + [[package]] name = "bytemuck" version = "1.5.1" @@ -310,6 +321,28 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" +[[package]] +name = "git-version" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94918e83f1e01dedc2e361d00ce9487b14c58c7f40bab148026fa39d42cb41e2" +dependencies = [ + "git-version-macro", + "proc-macro-hack", +] + +[[package]] +name = "git-version-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34a97a52fdee1870a34fa6e4b77570cba531b27d1838874fef4429a791a3d657" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "git2" version = "0.13.19" @@ -333,6 +366,7 @@ dependencies = [ "asyncgit", "backtrace", "bitflags", + "bugreport", "bytesize", "chrono", "clap", @@ -754,6 +788,12 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + [[package]] name = "proc-macro2" version = "1.0.26" @@ -943,6 +983,12 @@ dependencies = [ "syn", ] +[[package]] +name = "shell-escape" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + [[package]] name = "signal-hook" version = "0.1.17" @@ -1031,6 +1077,16 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "sys-info" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33fcecee49339531cf6bd84ecf3ed94f9c8ef4a7e700f2a1cac9cc1ca485383a" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "tempfile" version = "3.2.0" diff --git a/Cargo.toml b/Cargo.toml index d692c967..5a9fc994 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ unicode-width = "0.1" textwrap = "0.13" unicode-truncate = "0.2.0" easy-cast = "0.4" +bugreport = "0.4.0" [target.'cfg(all(target_family="unix",not(target_os="macos")))'.dependencies] which = "4.1" diff --git a/src/bug_report.rs b/src/bug_report.rs new file mode 100644 index 00000000..f9a6d135 --- /dev/null +++ b/src/bug_report.rs @@ -0,0 +1,33 @@ +use anyhow::Result; +use bugreport::{ + bugreport, + collector::{ + CommandLine, CompileTimeInformation, EnvironmentVariables, + FileContent, OperatingSystem, SoftwareVersion, + }, + format::Markdown, +}; + +use crate::get_app_config_path; + +pub fn generate_bugreport() -> Result<()> { + let mut config_file = get_app_config_path()?; + config_file.push("gitui/"); + + bugreport!() + .info(SoftwareVersion::default()) + .info(OperatingSystem::default()) + .info(CompileTimeInformation::default()) + .info(EnvironmentVariables::list(&["SHELL", "EDITOR"])) + .info(CommandLine::default()) + .info(FileContent::new( + "theme.ron", + config_file.with_file_name("theme.ron"), + )) + .info(FileContent::new( + "key_config.ron", + config_file.with_file_name("key_config.ron"), + )) + .print::(); + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 3263e6ce..1930da3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ // #![deny(clippy::expect_used)] mod app; +mod bug_report; mod clipboard; mod cmdbar; mod components; @@ -312,6 +313,11 @@ fn process_cmdline() -> Result { .short("l") .long("logging"), ) + .arg( + Arg::with_name("bugreport") + .help("Generate a bug report") + .long("bugreport"), + ) .arg( Arg::with_name("directory") .help("Set the working directory") @@ -321,10 +327,13 @@ fn process_cmdline() -> Result { ); let arg_matches = app.get_matches(); + if arg_matches.is_present("bugreport") { + bug_report::generate_bugreport()?; + std::process::exit(0); + } if arg_matches.is_present("logging") { setup_logging()?; } - if arg_matches.is_present("directory") { let directory = arg_matches.value_of("directory").unwrap_or(".");