diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-11-13 18:29:27 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-11-13 18:33:51 +0100 |
commit | 2dee992fe19cc32a2a769b9674c7876245518e5f (patch) | |
tree | fffc01efb4b2307ea1f9f772ea78008ef568efee /src/config | |
parent | 660896cf9d2fb5d7f3827bcfc617d1a48e1ee692 (diff) |
Add flag to show script, highlighted automatically
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/not_validated.rs | 18 | ||||
-rw-r--r-- | src/config/util.rs | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/config/not_validated.rs b/src/config/not_validated.rs index 8b17833..456cc2a 100644 --- a/src/config/not_validated.rs +++ b/src/config/not_validated.rs @@ -1,4 +1,5 @@ use std::path::PathBuf; +use anyhow::anyhow; use anyhow::Result; use getset::Getters; use handlebars::Handlebars; @@ -23,6 +24,10 @@ pub struct NotValidatedConfiguration { #[getset(get = "pub")] package_print_format: String, + #[serde(default = "default_script_highlight_theme")] + #[getset(get = "pub")] + script_highlight_theme: String, + #[serde(rename = "releases")] releases_directory: String, @@ -66,6 +71,19 @@ 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)) + } let hb = { let mut hb = Handlebars::new(); diff --git a/src/config/util.rs b/src/config/util.rs index 17aeadf..38939f0 100644 --- a/src/config/util.rs +++ b/src/config/util.rs @@ -15,3 +15,7 @@ pub fn default_package_print_format() -> String { "#)) } +pub fn default_script_highlight_theme() -> String { + String::from("base16-ocean.dark") +} + |