summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan P <eth-p+git@hidden.email>2021-01-10 13:57:05 -0800
committerDavid Peter <sharkdp@users.noreply.github.com>2021-02-16 09:11:27 +0100
commitf874c8e4dbb13defbb842398853cdea8e23e39d9 (patch)
tree623a6731c9358b1f8b7ad37e538f12fee79f93ca
parent025c5c061b8b79609e87e58d74858e9b90fc1458 (diff)
Use less binary specified in bat config for --diagnostic
-rw-r--r--src/bin/bat/main.rs4
-rw-r--r--src/config.rs9
2 files changed, 12 insertions, 1 deletions
diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs
index 13d5ddb5..1d430c30 100644
--- a/src/bin/bat/main.rs
+++ b/src/bin/bat/main.rs
@@ -229,6 +229,8 @@ fn run() -> Result<bool> {
if app.matches.is_present("diagnostic") {
use bugreport::{bugreport, collector::*, format::Markdown};
+ let pager = bat::config::get_pager_executable(app.matches.value_of("pager"))
+ .unwrap_or("less".to_owned()); // FIXME: Avoid non-canonical path to "less".
bugreport!()
.info(SoftwareVersion::default())
@@ -252,7 +254,7 @@ fn run() -> Result<bool> {
]))
.info(FileContent::new("Config file", config_file()))
.info(CompileTimeInformation::default())
- .info(CommandOutput::new("Less version", "less", &["--version"]))
+ .info(CommandOutput::new("Less version", pager, &["--version"]))
.print::<Markdown>();
return Ok(true);
diff --git a/src/config.rs b/src/config.rs
index 58d30a3b..6bb84ab9 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -84,6 +84,15 @@ pub struct Config<'a> {
pub highlighted_lines: HighlightedLineRanges,
}
+#[cfg(all(feature = "application", feature = "paging"))]
+pub fn get_pager_executable(config_pager: Option<&str>) -> Option<String> {
+ if let Ok(Some(pager)) = crate::pager::get_pager(config_pager) {
+ Some(pager.bin)
+ } else {
+ None
+ }
+}
+
#[test]
fn default_config_should_include_all_lines() {
use crate::line_range::RangeCheckResult;