mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-14 23:00:37 +01:00
parent
d2d29180a7
commit
397def1320
@ -1,6 +1,7 @@
|
|||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use app::Config;
|
use app::{Config, PagingMode};
|
||||||
use assets::HighlightingAssets;
|
use assets::HighlightingAssets;
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use inputfile::{InputFile, InputFileReader};
|
use inputfile::{InputFile, InputFileReader};
|
||||||
@ -19,7 +20,22 @@ impl<'b> Controller<'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&self) -> Result<bool> {
|
pub fn run(&self) -> Result<bool> {
|
||||||
let mut output_type = OutputType::from_mode(self.config.paging_mode, self.config.pager)?;
|
// Do not launch the pager if NONE of the input files exist
|
||||||
|
let mut paging_mode = self.config.paging_mode;
|
||||||
|
if self.config.paging_mode != PagingMode::Never {
|
||||||
|
let call_pager = self.config.files.iter().any(|file| {
|
||||||
|
if let InputFile::Ordinary(path) = file {
|
||||||
|
return Path::new(path).exists();
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if !call_pager {
|
||||||
|
paging_mode = PagingMode::Never;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut output_type = OutputType::from_mode(paging_mode, self.config.pager)?;
|
||||||
let writer = output_type.handle()?;
|
let writer = output_type.handle()?;
|
||||||
let mut no_errors: bool = true;
|
let mut no_errors: bool = true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user