Skip to content

Commit

Permalink
fixup! Add list scheme system
Browse files Browse the repository at this point in the history
  • Loading branch information
JamyGolden committed Nov 24, 2024
1 parent 0c2304c commit 482d1fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
26 changes: 22 additions & 4 deletions tinted-builder-rust/src/operations/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,30 @@ pub fn build(
.clone()
.unwrap_or(vec![SchemeSystem::default()]);

// Render list, otherwise generate
if supported_systems.contains(&SchemeSystem::List) {
let supported_systems = &[SchemeSystem::Base16, SchemeSystem::Base24];
render_list(
&theme_template_path,
supported_systems,
(template_item_config_name, template_item_config_value),
all_scheme_files.clone(),
is_quiet,
)?;
} else if supported_systems.contains(&SchemeSystem::ListBase16) {
let supported_systems = &[SchemeSystem::Base16];
render_list(
&theme_template_path,
supported_systems,
(template_item_config_name, template_item_config_value),
all_scheme_files.clone(),
is_quiet,
)?;
} else if supported_systems.contains(&SchemeSystem::ListBase24) {
let supported_systems = &[SchemeSystem::Base24];
render_list(
&theme_template_path,
supported_systems,
(template_item_config_name, template_item_config_value),
all_scheme_files.clone(),
is_quiet,
Expand Down Expand Up @@ -144,14 +165,11 @@ pub fn build(

fn render_list(
template_path: impl AsRef<Path>,
supported_systems: &[SchemeSystem],
(config_name, config_value): (&str, &TemplateConfig),
all_scheme_files: Vec<(PathBuf, Scheme)>,
is_quiet: bool,
) -> Result<()> {
let supported_systems = config_value
.supported_systems
.clone()
.unwrap_or(vec![SchemeSystem::default()]);
let filename = get_filename(config_value, is_quiet)?;
let mustache_template_path = template_path
.as_ref()
Expand Down
4 changes: 4 additions & 0 deletions tinted-builder/src/scheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pub enum SchemeSystem {
/// Base24 scheme system.
Base24,
List,
ListBase16,
ListBase24,
}

impl SchemeSystem {
Expand All @@ -89,6 +91,8 @@ impl SchemeSystem {
SchemeSystem::Base16 => "base16",
SchemeSystem::Base24 => "base24",
SchemeSystem::List => "list",
SchemeSystem::ListBase16 => "listbase16",
SchemeSystem::ListBase24 => "listbase24",
}
}
pub fn variants() -> &'static [SchemeSystem] {
Expand Down
2 changes: 1 addition & 1 deletion tinted-builder/src/scheme/base16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'de> Deserialize<'de> for Base16Scheme {
)));
}
}
SchemeSystem::List => {
_ => {
return Err(serde::de::Error::custom(format!(
"{} is not a valid Scheme system for a specific scheme",
wrapper.system
Expand Down

0 comments on commit 482d1fc

Please sign in to comment.