summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrhysd <lin90162@yahoo.co.jp>2021-10-17 13:34:49 +0900
committerDavid Peter <sharkdp@users.noreply.github.com>2021-10-17 21:22:57 +0200
commited3246c423932561435d45c50fd8cd9e06add7f5 (patch)
tree289254390b584419bcdbd62c5ed7442815d01237
parent2339d78bf4cb32a5aa54699bc97ffe6c369eec69 (diff)
Make grep-cli optional dependency
-rw-r--r--Cargo.toml4
-rw-r--r--src/bin/bat/main.rs9
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::<Markdown>();