@@ -1,8 +1,9 @@
11use std::io::{self, Write};
2−use std::path::Path;
32
43use crate::assets::HighlightingAssets;
5−use crate::config::{Config, PagingMode};
4+use crate::config::Config;
5+#[cfg(feature = "paging")]
6+use crate::config::PagingMode;
67use crate::errors::*;
78use crate::inputfile::{InputFile, InputFileReader};
89use crate::line_range::{LineRanges, RangeCheckResult};
@@ -24,22 +25,34 @@ impl<'b> Controller<'b> {
2425 }
2526
2627 pub fn run_with_error_handler(&self, handle_error: impl Fn(&Error)) -> Result<bool> {
27− // Do not launch the pager if NONE of the input files exist
28− let mut paging_mode = self.config.paging_mode;
29− if self.config.paging_mode != PagingMode::Never {
30− let call_pager = self.config.files.iter().any(|file| {
31− if let InputFile::Ordinary(path) = file {
32− return Path::new(path).exists();
33− } else {
34− return true;
28+ let mut output_type;
29+
30+ #[cfg(feature = "paging")]
31+ {
32+ use std::path::Path;
33+
34+ // Do not launch the pager if NONE of the input files exist
35+ let mut paging_mode = self.config.paging_mode;
36+ if self.config.paging_mode != PagingMode::Never {
37+ let call_pager = self.config.files.iter().any(|file| {
38+ if let InputFile::Ordinary(path) = file {
39+ return Path::new(path).exists();
40+ } else {
41+ return true;
42+ }
43+ });
44+ if !call_pager {
45+ paging_mode = PagingMode::Never;
3546 }
36− });
37− if !call_pager {
38− paging_mode = PagingMode::Never;
3947 }
48+ output_type = OutputType::from_mode(paging_mode, self.config.pager)?;
49+ }
50+
51+ #[cfg(not(feature = "paging"))]
52+ {
53+ output_type = OutputType::stdout();
4054 }
4155
42− let mut output_type = OutputType::from_mode(paging_mode, self.config.pager)?;
4356 let writer = output_type.handle()?;
4457 let mut no_errors: bool = true;
4558