1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-06 19:21:43 +00:00

Refactor InputDescription API into Input API

This commit is contained in:
Ethan P
2020-05-16 15:06:43 -07:00
committed by David Peter
parent 11a72ab765
commit 798b742617
5 changed files with 137 additions and 54 deletions
+3 -3
View File
@@ -257,7 +257,7 @@ impl App {
let files: Option<Vec<&OsStr>> = self.matches.values_of_os("FILE").map(|vs| vs.collect());
if files.is_none() {
let input = Input::stdin().with_name(filenames_or_none.next().unwrap_or(None));
let input = Input::stdin().as_file(filenames_or_none.next().unwrap_or(None));
return Ok(vec![input]);
}
let files_or_none: Box<dyn Iterator<Item = _>> = match files {
@@ -269,9 +269,9 @@ impl App {
for (filepath, provided_name) in files_or_none.zip(filenames_or_none) {
if let Some(filepath) = filepath {
if filepath.to_str().unwrap_or_default() == "-" {
file_input.push(Input::stdin().with_name(provided_name));
file_input.push(Input::stdin().as_file(provided_name));
} else {
file_input.push(Input::ordinary_file(filepath).with_name(provided_name));
file_input.push(Input::ordinary_file(filepath).as_file(provided_name));
}
}
}
-2
View File
@@ -25,7 +25,6 @@ use assets::{assets_from_cache_or_binary, cache_dir, clear_assets, config_dir};
use clap::crate_version;
use directories::PROJECT_DIRS;
use bat::input::InputDescription;
use bat::{
assets::HighlightingAssets,
config::Config,
@@ -124,7 +123,6 @@ pub fn list_languages(config: &Config) -> Result<()> {
fn theme_preview_file<'a>() -> Input<'a> {
Input::from_reader(Box::new(BufReader::new(THEME_PREVIEW_DATA)))
.with_name(Some("theme.rs".as_ref()))
.with_description(Some(InputDescription::new("")))
}
pub fn list_themes(cfg: &Config) -> Result<()> {