mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-14 01:02:25 +01:00
Allow specifying the theme via the BAT_THEME
environment variable
The `--theme` command line option stills takes precedence and this change preserves how errors are handled when it's used: If a theme name that doesn't exist is specified using the argument, this error is fatal. However, if a theme that doesn't exist is specified using the environment variable, the error is logged to `stderr` and the "Default" theme is loaded as a fallback.
This commit is contained in:
committed by
David Peter
parent
6b57f4eebc
commit
c68aa0f424
@@ -132,6 +132,10 @@ impl HighlightingAssets {
|
||||
})?)
|
||||
}
|
||||
|
||||
pub fn theme_exists(&self, theme: &str) -> bool {
|
||||
self.theme_set.themes.contains_key(theme)
|
||||
}
|
||||
|
||||
pub fn get_syntax(&self, language: Option<&str>, filename: Option<&str>) -> &SyntaxDefinition {
|
||||
let syntax = match (language, filename) {
|
||||
(Some(language), _) => self.syntax_set.find_syntax_by_token(language),
|
||||
|
Reference in New Issue
Block a user