diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-11-13 18:33:41 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-11-13 18:33:51 +0100 |
commit | 20cb64970dae30bacc58fa7af8ded258142e316a (patch) | |
tree | 4db2c316d70a6d111dcfaa44cf946393fd2eac0f /src/config | |
parent | 2dee992fe19cc32a2a769b9674c7876245518e5f (diff) |
Make highlighting optional
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/not_validated.rs | 29 | ||||
-rw-r--r-- | src/config/util.rs | 4 |
2 files changed, 15 insertions, 18 deletions
diff --git a/src/config/not_validated.rs b/src/config/not_validated.rs index 456cc2a..87bb816 100644 --- a/src/config/not_validated.rs +++ b/src/config/not_validated.rs @@ -24,9 +24,8 @@ pub struct NotValidatedConfiguration { #[getset(get = "pub")] package_print_format: String, - #[serde(default = "default_script_highlight_theme")] #[getset(get = "pub")] - script_highlight_theme: String, + script_highlight_theme: Option<String>, #[serde(rename = "releases")] releases_directory: String, @@ -71,18 +70,20 @@ pub struct NotValidatedConfiguration { impl<'reg> NotValidatedConfiguration { pub fn validate(self) -> Result<Configuration<'reg>> { // TODO: Implement proper validation - let allowed_theme_present = [ - "base16-ocean.dark", - "base16-eighties.dark", - "base16-mocha.dark", - "base16-ocean.light", - "InspiredGitHub", - "Solarized (dark)", - "Solarized (light)", - ].into_iter().any(|allowed_theme| self.script_highlight_theme == *allowed_theme); - - if !allowed_theme_present { - return Err(anyhow!("Theme not known: {}", self.script_highlight_theme)) + if let Some(configured_theme) = self.script_highlight_theme.as_ref() { + let allowed_theme_present = [ + "base16-ocean.dark", + "base16-eighties.dark", + "base16-mocha.dark", + "base16-ocean.light", + "InspiredGitHub", + "Solarized (dark)", + "Solarized (light)", + ].into_iter().any(|allowed_theme| configured_theme == *allowed_theme); + + if !allowed_theme_present { + return Err(anyhow!("Theme not known: {}", configured_theme)) + } } let hb = { diff --git a/src/config/util.rs b/src/config/util.rs index 38939f0..17aeadf 100644 --- a/src/config/util.rs +++ b/src/config/util.rs @@ -15,7 +15,3 @@ pub fn default_package_print_format() -> String { "#)) } -pub fn default_script_highlight_theme() -> String { - String::from("base16-ocean.dark") -} - |