on master help sign in
Use less binary specified in bat config for --diagnostic
commitf874c8e4dbb13defbb842398853cdea8e23e39d9 authorEthan P <eth-p+git@hidden.email> dateSun 10 Jan 2021, 13:57 (6 years ago) parent025c5c0
2 files changed+12−1
src/bin/bat/main.rs+3−1 src/config.rs+9
src/bin/bat/main.rs+3−1
@@ -229,6 +229,8 @@ fn run() -> Result<bool> {
229229
230230 if app.matches.is_present("diagnostic") {
231231 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".
232234
233235 bugreport!()
234236 .info(SoftwareVersion::default())
@@ -252,7 +254,7 @@ fn run() -> Result<bool> {
252254 ]))
253255 .info(FileContent::new("Config file", config_file()))
254256 .info(CompileTimeInformation::default())
255− .info(CommandOutput::new("Less version", "less", &["--version"]))
257+ .info(CommandOutput::new("Less version", pager, &["--version"]))
256258 .print::<Markdown>();
257259
258260 return Ok(true);
src/config.rs+9
@@ -84,6 +84,15 @@ pub struct Config<'a> {
8484 pub highlighted_lines: HighlightedLineRanges,
8585}
8686
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+
8796#[test]
8897fn default_config_should_include_all_lines() {
8998 use crate::line_range::RangeCheckResult;