From 29daac9014b25b9bb3c6d89cd0da96a3593097aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Pe=CC=81rez?= Date: Wed, 24 Dec 2025 05:13:35 +0000 Subject: [PATCH] chore: fix code format --- crates/typedialog-prov-gen/src/main.rs | 102 +++++++++--------- .../src/template/loader.rs | 5 +- 2 files changed, 53 insertions(+), 54 deletions(-) diff --git a/crates/typedialog-prov-gen/src/main.rs b/crates/typedialog-prov-gen/src/main.rs index f14b3f4..2f95365 100644 --- a/crates/typedialog-prov-gen/src/main.rs +++ b/crates/typedialog-prov-gen/src/main.rs @@ -136,59 +136,61 @@ async fn main() -> Result<(), Box> { match Config::load(cli.config.as_deref()) { Ok(config) => match TemplateLoader::new(&config) { Ok(loader) => match loader.list_templates() { - Ok(categories) => { - match format.as_str() { - "json" => { - if let Ok(json) = serde_json::to_string_pretty(&categories) { - println!("{}", json); - } else { - eprintln!("Failed to serialize templates to JSON"); - std::process::exit(1); - } - } - "yaml" => { - if let Ok(yaml) = serde_yaml::to_string(&categories) { - println!("{}", yaml); - } else { - eprintln!("Failed to serialize templates to YAML"); - std::process::exit(1); - } - } - "toml" => { - use serde::Serialize; - #[derive(Serialize)] - struct TemplatesWrapper { - categories: Vec, - } - let wrapped = TemplatesWrapper { categories }; - if let Ok(toml) = toml::to_string_pretty(&wrapped) { - println!("{}", toml); - } else { - eprintln!("Failed to serialize templates to TOML"); - std::process::exit(1); - } - } - "text" => { - println!("From: {}\n", loader.templates_dir().display()); - println!("📋 Available Template Categories:\n"); - for category in categories { - println!( - "{} {}", - category.name.to_uppercase(), - category.description - ); - for template in &category.templates { - println!(" • {}", template); - } - println!(); - } - } - _ => { - eprintln!("Unknown format: {}. Supported: json, yaml, text, toml", format); + Ok(categories) => match format.as_str() { + "json" => { + if let Ok(json) = serde_json::to_string_pretty(&categories) { + println!("{}", json); + } else { + eprintln!("Failed to serialize templates to JSON"); std::process::exit(1); } } - } + "yaml" => { + if let Ok(yaml) = serde_yaml::to_string(&categories) { + println!("{}", yaml); + } else { + eprintln!("Failed to serialize templates to YAML"); + std::process::exit(1); + } + } + "toml" => { + use serde::Serialize; + #[derive(Serialize)] + struct TemplatesWrapper { + categories: + Vec, + } + let wrapped = TemplatesWrapper { categories }; + if let Ok(toml) = toml::to_string_pretty(&wrapped) { + println!("{}", toml); + } else { + eprintln!("Failed to serialize templates to TOML"); + std::process::exit(1); + } + } + "text" => { + println!("From: {}\n", loader.templates_dir().display()); + println!("📋 Available Template Categories:\n"); + for category in categories { + println!( + "{} {}", + category.name.to_uppercase(), + category.description + ); + for template in &category.templates { + println!(" • {}", template); + } + println!(); + } + } + _ => { + eprintln!( + "Unknown format: {}. Supported: json, yaml, text, toml", + format + ); + std::process::exit(1); + } + }, Err(e) => { eprintln!("Failed to list templates: {}", e); std::process::exit(1); diff --git a/crates/typedialog-prov-gen/src/template/loader.rs b/crates/typedialog-prov-gen/src/template/loader.rs index 38e3e36..30ecb59 100644 --- a/crates/typedialog-prov-gen/src/template/loader.rs +++ b/crates/typedialog-prov-gen/src/template/loader.rs @@ -39,10 +39,7 @@ impl TemplateLoader { if !templates_dir.exists() { return Err(std::io::Error::new( std::io::ErrorKind::NotFound, - format!( - "Templates directory not found: {}", - templates_dir.display() - ), + format!("Templates directory not found: {}", templates_dir.display()), ) .into()); }