chore: fix code format
Some checks failed
CI / Lint (bash) (push) Has been cancelled
CI / Lint (markdown) (push) Has been cancelled
CI / Lint (nickel) (push) Has been cancelled
CI / Lint (nushell) (push) Has been cancelled
CI / Lint (rust) (push) Has been cancelled
CI / Benchmark (push) Has been cancelled
CI / Security Audit (push) Has been cancelled
CI / License Compliance (push) Has been cancelled
CI / Code Coverage (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (macos-latest) (push) Has been cancelled
CI / Build (ubuntu-latest) (push) Has been cancelled
CI / Build (windows-latest) (push) Has been cancelled
Some checks failed
CI / Lint (bash) (push) Has been cancelled
CI / Lint (markdown) (push) Has been cancelled
CI / Lint (nickel) (push) Has been cancelled
CI / Lint (nushell) (push) Has been cancelled
CI / Lint (rust) (push) Has been cancelled
CI / Benchmark (push) Has been cancelled
CI / Security Audit (push) Has been cancelled
CI / License Compliance (push) Has been cancelled
CI / Code Coverage (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (macos-latest) (push) Has been cancelled
CI / Build (ubuntu-latest) (push) Has been cancelled
CI / Build (windows-latest) (push) Has been cancelled
This commit is contained in:
parent
254833f3ed
commit
29daac9014
@ -136,59 +136,61 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<typedialog_prov_gen::template::TemplateCategory>,
|
||||
}
|
||||
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<typedialog_prov_gen::template::TemplateCategory>,
|
||||
}
|
||||
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);
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user