Make grep-cli optional dependency

This commit is contained in:
rhysd 2021-10-17 13:34:49 +09:00 committed by David Peter
parent 2339d78bf4
commit ed3246c423
2 changed files with 6 additions and 7 deletions

View File

@ -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"

View File

@ -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>();