Add validators schema and code templates

This commit is contained in:
2026-01-30 07:11:05 +00:00
parent a1775a8943
commit 4a9ffe85e1

View File

@@ -0,0 +1,45 @@
use clap::{Parser, Subcommand};
/// {{spec.description}}
#[derive(Parser, Debug)]
#[command(name = "{{spec.name}}")]
#[command(version = "{{spec.version}}")]
#[command(author = "{{spec.author}}")]
#[command(about = "{{escape description}}")]
struct Args {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand, Debug)]
enum Command {
{{#each spec.commands}}
/// {{escape description}}
{{pascalCase name}} {
{{#each arguments}}
/// {{escape description}}
{{#if variadic}}...{{/if}}{{rustArgType type required variadic}} {{camelCase name}},
{{/each}}
{{#each options}}
/// {{escape description}}
#[arg(short, long{{#if default}}, default_value = "{{defaultValue}}"{{/if}})]
{{camelCase name}}: {{toRustType type}},
{{/each}}
},
{{/each}}
}
fn main() {
let args = Args::parse();
match args.command {
{{#each spec.commands}}
Some(Command::{{pascalCase name}} { .. }) => {
println!("Running {{name}} command");
}
{{/each}}
None => {
println!("Use --help to see available commands");
}
}
}