|
|
|
@ -10,7 +10,6 @@ use crate::paging::PagingMode;
|
|
|
|
|
#[cfg(feature = "paging")]
|
|
|
|
|
use crate::wrapping::WrappingMode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "paging")]
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
|
enum SingleScreenAction {
|
|
|
|
@ -18,7 +17,6 @@ enum SingleScreenAction {
|
|
|
|
|
Nothing,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub enum OutputType {
|
|
|
|
|
#[cfg(feature = "paging")]
|
|
|
|
@ -28,11 +26,17 @@ pub enum OutputType {
|
|
|
|
|
|
|
|
|
|
impl OutputType {
|
|
|
|
|
#[cfg(feature = "paging")]
|
|
|
|
|
pub fn from_mode(paging_mode: PagingMode, wrapping_mode: WrappingMode, pager: Option<&str>) -> Result<Self> {
|
|
|
|
|
pub fn from_mode(
|
|
|
|
|
paging_mode: PagingMode,
|
|
|
|
|
wrapping_mode: WrappingMode,
|
|
|
|
|
pager: Option<&str>,
|
|
|
|
|
) -> Result<Self> {
|
|
|
|
|
use self::PagingMode::*;
|
|
|
|
|
Ok(match paging_mode {
|
|
|
|
|
Always => OutputType::try_pager(SingleScreenAction::Nothing, wrapping_mode, pager)?,
|
|
|
|
|
QuitIfOneScreen => OutputType::try_pager(SingleScreenAction::Quit, wrapping_mode, pager)?,
|
|
|
|
|
QuitIfOneScreen => {
|
|
|
|
|
OutputType::try_pager(SingleScreenAction::Quit, wrapping_mode, pager)?
|
|
|
|
|
}
|
|
|
|
|
_ => OutputType::stdout(),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -42,7 +46,7 @@ impl OutputType {
|
|
|
|
|
fn try_pager(
|
|
|
|
|
single_screen_action: SingleScreenAction,
|
|
|
|
|
wrapping_mode: WrappingMode,
|
|
|
|
|
pager_from_config: Option<&str>
|
|
|
|
|
pager_from_config: Option<&str>,
|
|
|
|
|
) -> Result<Self> {
|
|
|
|
|
use std::env;
|
|
|
|
|
use std::ffi::OsString;
|
|
|
|
|