From ed3246c423932561435d45c50fd8cd9e06add7f5 Mon Sep 17 00:00:00 2001 From: rhysd Date: Sun, 17 Oct 2021 13:34:49 +0900 Subject: [PATCH] Make grep-cli optional dependency --- Cargo.toml | 4 ++-- src/bin/bat/main.rs | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8a18b4c3..a47bddc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ minimal-application = [ "wild", ] git = ["git2"] # Support indicating git modifications -paging = ["shell-words"] # Support applying a pager on the output +paging = ["shell-words", "grep-cli"] # Support applying a pager on the output # Add "syntect/plist-load" when https://github.com/trishume/syntect/pull/345 reaches us build-assets = ["syntect/yaml-load", "syntect/dump-create"] @@ -64,7 +64,7 @@ path_abs = { version = "0.5", default-features = false } clircle = "0.3" bugreport = { version = "0.4", optional = true } dirs-next = { version = "2.0.0", optional = true } -grep-cli = "0.1.6" +grep-cli = { version = "0.1.6", optional = true } [dependencies.git2] version = "0.13" diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 891aace8..53e246d1 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -229,7 +229,7 @@ fn invoke_bugreport(app: &App) { let pager = bat::config::get_pager_executable(app.matches.value_of("pager")) .unwrap_or_else(|| "less".to_owned()); // FIXME: Avoid non-canonical path to "less". - let report = bugreport!() + let mut report = bugreport!() .info(SoftwareVersion::default()) .info(OperatingSystem::default()) .info(CommandLine::default()) @@ -255,14 +255,13 @@ fn invoke_bugreport(app: &App) { .info(FileContent::new("Config file", config_file())) .info(CompileTimeInformation::default()); - let mut report = if let Ok(resolved_path) = grep_cli::resolve_binary(pager) { - report.info(CommandOutput::new( + #[cfg(feature = "paging")] + if let Ok(resolved_path) = grep_cli::resolve_binary(pager) { + report = report.info(CommandOutput::new( "Less version", resolved_path, &["--version"], )) - } else { - report }; report.print::();