1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-03-15 15:18:45 +00:00

address comments

This commit is contained in:
rleungx 2018-05-11 19:39:43 +08:00
parent ad59045253
commit b69c70b408
2 changed files with 7 additions and 9 deletions

View File

@ -127,11 +127,12 @@ impl HighlightingAssets {
} }
pub fn get_theme(&self, theme: &str) -> Result<&Theme> { pub fn get_theme(&self, theme: &str) -> Result<&Theme> {
let err = format!("Could not find '{}' theme", theme); Ok(self.theme_set.themes.get(theme).ok_or_else(|| {
Ok(self.theme_set io::Error::new(
.themes io::ErrorKind::Other,
.get(theme) format!("Could not find '{}' theme", theme),
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, err))?) )
})?)
} }
} }

View File

@ -223,10 +223,7 @@ fn run() -> Result<()> {
let config = app.config()?; let config = app.config()?;
let assets = HighlightingAssets::new(); let assets = HighlightingAssets::new();
let theme = match config.theme { let theme = assets.get_theme(config.theme.unwrap_or("Default"))?;
Some(t) => assets.get_theme(t)?,
None => assets.get_theme("Default")?
};
if app.matches.is_present("list-languages") { if app.matches.is_present("list-languages") {
let languages = assets.syntax_set.syntaxes(); let languages = assets.syntax_set.syntaxes();