on master help sign in
Make grep-cli optional dependency
commited3246c423932561435d45c50fd8cd9e06add7f5 authorrhysd <lin90162@yahoo.co.jp> dateSun 17 Oct 2021, 13:34 (5 years ago) parent2339d78
2 files changed+6−7
Cargo.toml+2−2 src/bin/bat/main.rs+4−5
Cargo.toml+2−2
@@ -33,7 +33,7 @@ minimal-application = [
3333 "wild",
3434]
3535git = ["git2"] # Support indicating git modifications
36−paging = ["shell-words"] # Support applying a pager on the output
36+paging = ["shell-words", "grep-cli"] # Support applying a pager on the output
3737# Add "syntect/plist-load" when https://github.com/trishume/syntect/pull/345 reaches us
3838build-assets = ["syntect/yaml-load", "syntect/dump-create"]
3939
@@ -64,7 +64,7 @@ path_abs = { version = "0.5", default-features = false }
6464clircle = "0.3"
6565bugreport = { version = "0.4", optional = true }
6666dirs-next = { version = "2.0.0", optional = true }
67−grep-cli = "0.1.6"
67+grep-cli = { version = "0.1.6", optional = true }
6868
6969[dependencies.git2]
7070version = "0.13"
src/bin/bat/main.rs+4−5
@@ -229,7 +229,7 @@ fn invoke_bugreport(app: &App) {
229229 let pager = bat::config::get_pager_executable(app.matches.value_of("pager"))
230230 .unwrap_or_else(|| "less".to_owned()); // FIXME: Avoid non-canonical path to "less".
231231
232− let report = bugreport!()
232+ let mut report = bugreport!()
233233 .info(SoftwareVersion::default())
234234 .info(OperatingSystem::default())
235235 .info(CommandLine::default())
@@ -255,14 +255,13 @@ fn invoke_bugreport(app: &App) {
255255 .info(FileContent::new("Config file", config_file()))
256256 .info(CompileTimeInformation::default());
257257
258− let mut report = if let Ok(resolved_path) = grep_cli::resolve_binary(pager) {
259− report.info(CommandOutput::new(
258+ #[cfg(feature = "paging")]
259+ if let Ok(resolved_path) = grep_cli::resolve_binary(pager) {
260+ report = report.info(CommandOutput::new(
260261 "Less version",
261262 resolved_path,
262263 &["--version"],
263264 ))
264− } else {
265− report
266265 };
267266
268267 report.print::<Markdown>();