Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add ability to warn on missing theme values (#3705)
Marshall Bowers912f7e6c1a14
diff --git a/Cargo.lock b/Cargo.lockindex 0a4801524ea..cb0d54022f2 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -9813,6 +9813,7 @@ name = "theme_importer"version = "0.1.0"dependencies = ["anyhow",+ "clap 4.4.4","convert_case 0.6.0","gpui2","indexmap 1.9.3",diff --git a/crates/theme_importer/Cargo.toml b/crates/theme_importer/Cargo.tomlindex 82ab18d48d2..4b8641faa47 100644--- a/crates/theme_importer/Cargo.toml+++ b/crates/theme_importer/Cargo.toml@@ -8,6 +8,7 @@ publish = false[dependencies]anyhow.workspace = true+clap = { version = "4.4", features = ["derive"] }convert_case = "0.6.0"gpui = { package = "gpui2", path = "../gpui2" }indexmap = { version = "1.6.2", features = ["serde"] }diff --git a/crates/theme_importer/src/main.rs b/crates/theme_importer/src/main.rsindex 0005d932d4a..a02b1ca1149 100644--- a/crates/theme_importer/src/main.rs+++ b/crates/theme_importer/src/main.rs@@ -10,6 +10,7 @@ use std::process::Command;use std::str::FromStr;use anyhow::{anyhow, Context, Result};+use clap::Parser;use convert_case::{Case, Casing};use gpui::serde_json;use indexmap::IndexMap;@@ -61,16 +62,34 @@ pub struct ThemeMetadata {pub appearance: ThemeAppearanceJson,}+#[derive(Parser)]+#[command(author, version, about, long_about = None)]+struct Args {+ /// Whether to warn when values are missing from the theme.+ #[arg(long)]+ warn_on_missing: bool,+}+fn main() -> Result<()> {const SOURCE_PATH: &str = "assets/themes/src/vscode";const OUT_PATH: &str = "crates/theme2/src/themes";- let log_config = simplelog::ConfigBuilder::new()- .set_level_color(log::Level::Trace, simplelog::Color::Cyan)- .set_level_color(log::Level::Info, simplelog::Color::Blue)- .set_level_color(log::Level::Warn, simplelog::Color::Yellow)- .set_level_color(log::Level::Error, simplelog::Color::Red)- .build();+ let args = Args::parse();++ let log_config = {+ let mut config = simplelog::ConfigBuilder::new();+ config+ .set_level_color(log::Level::Trace, simplelog::Color::Cyan)+ .set_level_color(log::Level::Info, simplelog::Color::Blue)+ .set_level_color(log::Level::Warn, simplelog::Color::Yellow)+ .set_level_color(log::Level::Error, simplelog::Color::Red);++ if !args.warn_on_missing {+ config.add_filter_ignore_str("theme_printer");+ }++ config.build()+ };TermLogger::init(LevelFilter::Trace, log_config, TerminalMode::Mixed).expect("could not initialize logger");diff --git a/crates/theme_importer/src/theme_printer.rs b/crates/theme_importer/src/theme_printer.rsindex 4726c90c6d1..13123d854f9 100644--- a/crates/theme_importer/src/theme_printer.rs+++ b/crates/theme_importer/src/theme_printer.rs@@ -282,6 +282,8 @@ impl<'a> Debug for ThemeColorsRefinementPrinter<'a> {HslaPrinter(color).fmt(f)?;f.write_str(")")?;f.write_str(",")?;+ } else {+ log::warn!(target: "theme_printer", "No value for '{}' in theme", color_name);}}