use clap::{Parser, Subcommand}; use std::process; use yampl; #[derive(Parser)] #[command( author="semichkin", version="0.0.10", about="cli utility for rendering templates with args described in yaml file", long_about = None )] pub struct Cli { #[command(subcommand)] pub command: Option, } #[derive(Subcommand)] pub enum Commands { Render { #[arg(short = 'c', long = "config")] config: String, #[arg(short = 'o', long = "output")] output: String, }, } pub fn main() { let c = Cli::parse(); let res = match &c.command { Some(Commands::Render { config, output }) => yampl::render(config.clone(), output.clone()), None => Ok(()), }; if let Err(e) = res { println!("{}", e); process::exit(1); }; }