use fresh::config::Config;
use fresh::view::theme::ThemeFile;
use schemars::schema_for;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let schema_type = args.get(1).map(|s| s.as_str()).unwrap_or("config");
let json: serde_json::Value = match schema_type {
"config" => {
let schema = schema_for!(Config);
let mut json = serde_json::to_value(&schema).expect("Failed to serialize schema");
if let Some(properties) = json.get_mut("properties") {
if let Some(menu) = properties.get_mut("menu") {
if let Some(obj) = menu.as_object_mut() {
obj.remove("default");
}
}
}
json
}
"theme" => {
let schema = schema_for!(ThemeFile);
serde_json::to_value(&schema).expect("Failed to serialize schema")
}
other => {
eprintln!("Unknown schema type: {}. Use 'config' or 'theme'.", other);
std::process::exit(1);
}
};
let output = serde_json::to_string_pretty(&json).expect("Failed to serialize schema");
println!("{}", output);
}