mirror of
https://github.com/sharkdp/bat
synced 2026-08-08 19:41:45 +00:00
Remove custom 'transpose' function
This commit is contained in:
+10
-10
@@ -23,7 +23,6 @@ use bat::{
|
||||
line_range::{LineRange, LineRanges},
|
||||
style::{OutputComponent, OutputComponents, OutputWrap},
|
||||
syntax_mapping::SyntaxMapping,
|
||||
util::transpose,
|
||||
Config, PagingMode,
|
||||
};
|
||||
|
||||
@@ -198,12 +197,11 @@ impl App {
|
||||
.or_else(|| env::var("BAT_THEME").ok())
|
||||
.unwrap_or_else(|| String::from(BAT_THEME_DEFAULT)),
|
||||
line_ranges: LineRanges::from(
|
||||
transpose(
|
||||
self.matches
|
||||
.values_of("line-range")
|
||||
.map(|vs| vs.map(LineRange::from).collect()),
|
||||
)?
|
||||
.unwrap_or_else(|| vec![]),
|
||||
self.matches
|
||||
.values_of("line-range")
|
||||
.map(|vs| vs.map(LineRange::from).collect())
|
||||
.transpose()?
|
||||
.unwrap_or_else(|| vec![]),
|
||||
),
|
||||
output_components,
|
||||
syntax_mapping,
|
||||
@@ -247,13 +245,15 @@ impl App {
|
||||
} else if matches.is_present("plain") {
|
||||
[OutputComponent::Plain].iter().cloned().collect()
|
||||
} else {
|
||||
let env_style_components: Option<Vec<OutputComponent>> =
|
||||
transpose(env::var("BAT_STYLE").ok().map(|style_str| {
|
||||
let env_style_components: Option<Vec<OutputComponent>> = env::var("BAT_STYLE")
|
||||
.ok()
|
||||
.map(|style_str| {
|
||||
style_str
|
||||
.split(',')
|
||||
.map(|x| OutputComponent::from_str(&x))
|
||||
.collect::<Result<Vec<OutputComponent>>>()
|
||||
}))?;
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
matches
|
||||
.value_of("style")
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::path::PathBuf;
|
||||
|
||||
use shell_words;
|
||||
|
||||
use bat::{dirs::PROJECT_DIRS, util::transpose};
|
||||
use bat::dirs::PROJECT_DIRS;
|
||||
|
||||
pub fn config_file() -> PathBuf {
|
||||
env::var("BAT_CONFIG_PATH")
|
||||
@@ -16,12 +16,11 @@ pub fn config_file() -> PathBuf {
|
||||
}
|
||||
|
||||
pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseError> {
|
||||
Ok(transpose(
|
||||
fs::read_to_string(config_file())
|
||||
.ok()
|
||||
.map(|content| get_args_from_str(&content)),
|
||||
)?
|
||||
.unwrap_or_else(|| vec![]))
|
||||
Ok(fs::read_to_string(config_file())
|
||||
.ok()
|
||||
.map(|content| get_args_from_str(&content))
|
||||
.transpose()?
|
||||
.unwrap_or_else(|| vec![]))
|
||||
}
|
||||
|
||||
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
|
||||
|
||||
Reference in New Issue
Block a user