Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Improve schema_generator CLI (#25898)
Peter Tripp7a9e0b37ed5c
diff --git a/crates/schema_generator/README.md b/crates/schema_generator/README.mdnew file mode 100644index 00000000000..f8ef5bc234f--- /dev/null+++ b/crates/schema_generator/README.md@@ -0,0 +1,12 @@+# Zed Schema Generator++Prints various Zed schemas to stdout.++## Usage++```sh+cargo run -p schema_generator -- --help++cargo run -p schema_generator -- theme+cargo run -p schema_generator -- icon_theme+```diff --git a/crates/schema_generator/src/main.rs b/crates/schema_generator/src/main.rsindex 2109dbd807c..a7e406a1a9c 100644--- a/crates/schema_generator/src/main.rs+++ b/crates/schema_generator/src/main.rs@@ -1,26 +1,36 @@use anyhow::Result;-use clap::Parser;+use clap::{Parser, ValueEnum};use schemars::schema_for;use theme::{IconThemeFamilyContent, ThemeFamilyContent};#[derive(Parser, Debug)]-struct Args {}+pub struct Args {+ #[arg(value_enum)]+ pub schema_type: SchemaType,+}++#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]+#[clap(rename_all = "snake_case")]+pub enum SchemaType {+ Theme,+ IconTheme,+}fn main() -> Result<()> {env_logger::init();- let _args = Args::parse();-- let theme_family_schema = schema_for!(ThemeFamilyContent);- println!("Theme Schema:");- println!("{}", serde_json::to_string_pretty(&theme_family_schema)?);+ let args = Args::parse();- let icon_theme_family_schema = schema_for!(IconThemeFamilyContent);- println!("Icon Theme Schema:");- println!(- "{}",- serde_json::to_string_pretty(&icon_theme_family_schema)?- );+ match args.schema_type {+ SchemaType::Theme => {+ let schema = schema_for!(ThemeFamilyContent);+ println!("{}", serde_json::to_string_pretty(&schema)?);+ }+ SchemaType::IconTheme => {+ let schema = schema_for!(IconThemeFamilyContent);+ println!("{}", serde_json::to_string_pretty(&schema)?);+ }+ }Ok(())}