Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
theme_importer: Add ability to print theme JSON schema (#7129)
Marshall Bowerse5fe811d7ad0
diff --git a/Cargo.lock b/Cargo.lockindex d8b069e39c2..87e56d599e5 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -8207,6 +8207,7 @@ dependencies = ["palette","pathfinder_color","rust-embed",+ "schemars","serde","serde_json","simplelog",diff --git a/crates/theme_importer/Cargo.toml b/crates/theme_importer/Cargo.tomlindex 6b5b5743f5d..2214af85c74 100644--- a/crates/theme_importer/Cargo.toml+++ b/crates/theme_importer/Cargo.toml@@ -18,6 +18,7 @@ log.workspace = truepalette = { version = "0.7.3", default-features = false, features = ["std"] }pathfinder_color = "0.5"rust-embed.workspace = true+schemars = { workspace = true, features = ["indexmap"] }serde.workspace = trueserde_json.workspace = truesimplelog = "0.9"diff --git a/crates/theme_importer/src/main.rs b/crates/theme_importer/src/main.rsindex 6f3dc83006c..a8cc8a1bdf7 100644--- a/crates/theme_importer/src/main.rs+++ b/crates/theme_importer/src/main.rs@@ -7,13 +7,14 @@ use std::fs::File;use std::path::PathBuf;use anyhow::{Context, Result};-use clap::Parser;+use clap::{Parser, Subcommand};use indexmap::IndexMap;use json_comments::StripComments;use log::LevelFilter;+use schemars::schema_for;use serde::Deserialize;use simplelog::{TermLogger, TerminalMode};-use theme::{Appearance, AppearanceContent};+use theme::{Appearance, AppearanceContent, ThemeFamilyContent};use crate::vscode::VsCodeTheme;use crate::vscode::VsCodeThemeConverter;@@ -74,6 +75,15 @@ struct Args {/// Whether to warn when values are missing from the theme.#[arg(long)]warn_on_missing: bool,++ #[command(subcommand)]+ command: Option<Command>,+}++#[derive(Subcommand)]+enum Command {+ /// Prints the JSON schema for a theme.+ PrintSchema,}fn main() -> Result<()> {@@ -97,6 +107,21 @@ fn main() -> Result<()> {TermLogger::init(LevelFilter::Trace, log_config, TerminalMode::Mixed).expect("could not initialize logger");+ if let Some(command) = args.command {+ match command {+ Command::PrintSchema => {+ let theme_family_schema = schema_for!(ThemeFamilyContent);++ println!(+ "{}",+ serde_json::to_string_pretty(&theme_family_schema).unwrap()+ );++ return Ok(());+ }+ }+ }+let theme_file_path = args.theme_path;let theme_file = match File::open(&theme_file_path) {