@@ -1,31 +1,39 @@
1−use std::env;
2−use std::ffi::OsString;
31use std::io::{self, Write};
4−use std::path::PathBuf;
5−use std::process::{Child, Command, Stdio};
2+#[cfg(feature = "paging")]
3+use std::process::Child;
64
75use crate::config::PagingMode;
86use crate::errors::*;
7+#[cfg(feature = "paging")]
98use crate::less::retrieve_less_version;
109
1110#[derive(Debug)]
1211pub enum OutputType {
12+ #[cfg(feature = "paging")]
1313 Pager(Child),
1414 Stdout(io::Stdout),
1515}
1616
1717impl OutputType {
1818 pub fn from_mode(mode: PagingMode, pager: Option<&str>) -> Result<Self> {
19− use self::PagingMode::*;
19+ let _ = pager;
2020 Ok(match mode {
21− Always => OutputType::try_pager(false, pager)?,
22− QuitIfOneScreen => OutputType::try_pager(true, pager)?,
21+ #[cfg(feature = "paging")]
22+ PagingMode::Always => OutputType::try_pager(false, pager)?,
23+ #[cfg(feature = "paging")]
24+ PagingMode::QuitIfOneScreen => OutputType::try_pager(true, pager)?,
2325 _ => OutputType::stdout(),
2426 })
2527 }
2628
2729 /// Try to launch the pager. Fall back to stdout in case of errors.
30+ #[cfg(feature = "paging")]
2831 fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> {
32+ use std::env;
33+ use std::ffi::OsString;
34+ use std::path::PathBuf;
35+ use std::process::{Command, Stdio};
36+
2937 let mut replace_arguments_to_less = false;
3038
3139 let pager_from_env = match (env::var("BAT_PAGER"), env::var("PAGER")) {
@@ -114,6 +122,7 @@ impl OutputType {
114122
115123 pub fn handle(&mut self) -> Result<&mut dyn Write> {
116124 Ok(match *self {
125+ #[cfg(feature = "paging")]
117126 OutputType::Pager(ref mut command) => command
118127 .stdin
119128 .as_mut()
@@ -123,6 +132,7 @@ impl OutputType {
123132 }
124133}
125134
135+#[cfg(feature = "paging")]
126136impl Drop for OutputType {
127137 fn drop(&mut self) {
128138 if let OutputType::Pager(ref mut command) = *self {