1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-07 19:31:42 +00:00

Rename InputFile => Input

This commit is contained in:
sharkdp
2020-04-21 21:19:06 +02:00
committed by David Peter
parent 1dc328ad49
commit f8d0956893
9 changed files with 82 additions and 84 deletions
+8 -8
View File
@@ -15,8 +15,8 @@ use console::Term;
use bat::{
config::{
Config, HighlightedLineRanges, InputFile, LineRange, LineRanges, MappingTarget,
OrdinaryFile, PagingMode, StyleComponent, StyleComponents, SyntaxMapping, WrappingMode,
Config, HighlightedLineRanges, Input, LineRange, LineRanges, MappingTarget, OrdinaryFile,
PagingMode, StyleComponent, StyleComponents, SyntaxMapping, WrappingMode,
},
errors::*,
HighlightingAssets,
@@ -73,7 +73,7 @@ impl App {
Ok(clap_app::build_app(interactive_output).get_matches_from(args))
}
pub fn config(&self, inputs: &[InputFile]) -> Result<Config> {
pub fn config(&self, inputs: &[Input]) -> Result<Config> {
let style_components = self.style_components()?;
let paging_mode = match self.matches.value_of("paging") {
@@ -84,7 +84,7 @@ impl App {
// If we have -pp as an option when in auto mode, the pager should be disabled.
PagingMode::Never
} else if inputs.iter().any(|f| {
if let InputFile::StdIn(None) = f {
if let Input::StdIn(None) = f {
true
} else {
false
@@ -226,7 +226,7 @@ impl App {
})
}
pub fn inputs(&self) -> Result<Vec<InputFile>> {
pub fn inputs(&self) -> Result<Vec<Input>> {
// verify equal length of file-names and input FILEs
match self.matches.values_of("file-name") {
Some(ref filenames)
@@ -251,7 +251,7 @@ impl App {
let files: Option<Vec<&OsStr>> = self.matches.values_of_os("FILE").map(|vs| vs.collect());
if files.is_none() {
return Ok(vec![InputFile::StdIn(
return Ok(vec![Input::StdIn(
filenames_or_none.nth(0).unwrap().map(|f| f.to_owned()),
)]);
}
@@ -264,13 +264,13 @@ impl App {
for (input, name) in files_or_none.zip(filenames_or_none) {
if let Some(input) = input {
if input.to_str().unwrap_or_default() == "-" {
file_input.push(InputFile::StdIn(name.map(|n| n.to_owned())));
file_input.push(Input::StdIn(name.map(|n| n.to_owned())));
} else {
let mut ofile = OrdinaryFile::from_path(input);
if let Some(path) = name {
ofile.set_provided_path(path);
}
file_input.push(InputFile::Ordinary(ofile))
file_input.push(Input::Ordinary(ofile))
}
}
}
+5 -5
View File
@@ -26,7 +26,7 @@ use clap::crate_version;
use directories::PROJECT_DIRS;
use bat::{
config::{Config, InputFile, OrdinaryFile, StyleComponent, StyleComponents},
config::{Config, Input, OrdinaryFile, StyleComponent, StyleComponents},
errors::*,
Controller, HighlightingAssets,
};
@@ -134,7 +134,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
)?;
config.theme = theme.to_string();
Controller::new(&config, &assets)
.run(vec![InputFile::ThemePreviewFile])
.run(vec![Input::ThemePreviewFile])
.ok();
writeln!(stdout)?;
}
@@ -147,7 +147,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
Ok(())
}
fn run_controller(inputs: Vec<InputFile>, config: &Config) -> Result<bool> {
fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
let assets = assets_from_cache_or_binary()?;
let controller = Controller::new(&config, &assets);
controller.run(inputs)
@@ -167,10 +167,10 @@ fn run() -> Result<bool> {
run_cache_subcommand(cache_matches)?;
Ok(true)
} else {
let inputs = vec![InputFile::Ordinary(OrdinaryFile::from_path(OsStr::new(
let inputs = vec![Input::Ordinary(OrdinaryFile::from_path(OsStr::new(
"cache",
)))];
let mut config = app.config(&inputs)?;
let config = app.config(&inputs)?;
run_controller(inputs, &config)
}