on master help sign in
Use less binary specified in bat config for --diagnostic
f874c8eEthan P
src/bin/bat/main.rs+3−1
@@ -229,6 +229,8 @@ fn run() -> Result<bool> {
229
229
230 if app.matches.is_present("diagnostic") {
230 if app.matches.is_present("diagnostic") {
231 use bugreport::{bugreport, collector::*, format::Markdown};
231 use bugreport::{bugreport, collector::*, format::Markdown};
232+ let pager = bat::config::get_pager_executable(app.matches.value_of("pager"))
233+ .unwrap_or("less".to_owned()); // FIXME: Avoid non-canonical path to "less".
232
234
233 bugreport!()
235 bugreport!()
234 .info(SoftwareVersion::default())
236 .info(SoftwareVersion::default())
@@ -252,7 +254,7 @@ fn run() -> Result<bool> {
252 ]))
254 ]))
253 .info(FileContent::new("Config file", config_file()))
255 .info(FileContent::new("Config file", config_file()))
254 .info(CompileTimeInformation::default())
256 .info(CompileTimeInformation::default())
255− .info(CommandOutput::new("Less version", "less", &["--version"]))
257+ .info(CommandOutput::new("Less version", pager, &["--version"]))
256 .print::<Markdown>();
258 .print::<Markdown>();
257
259
258 return Ok(true);
260 return Ok(true);
src/config.rs+9
@@ -84,6 +84,15 @@ pub struct Config<'a> {
84 pub highlighted_lines: HighlightedLineRanges,
84 pub highlighted_lines: HighlightedLineRanges,
85}
85}
86
86
87+#[cfg(all(feature = "application", feature = "paging"))]
88+pub fn get_pager_executable(config_pager: Option<&str>) -> Option<String> {
89+ if let Ok(Some(pager)) = crate::pager::get_pager(config_pager) {
90+ Some(pager.bin)
91+ } else {
92+ None
93+ }
94+}
95+
87#[test]
96#[test]
88fn default_config_should_include_all_lines() {
97fn default_config_should_include_all_lines() {
89 use crate::line_range::RangeCheckResult;
98 use crate::line_range::RangeCheckResult;