---
to: "{{ project_name }}/src/cmds/{{ noun }}/mod.rs"
vars:
  noun: "resource"
  noun_description: "Manage resources"
  verbs: ["create", "list", "get", "update", "delete"]
---
//! {{ noun_description }}

use clap::{Args, Subcommand};

{% for verb in verbs %}pub mod {{ verb }};
{% endfor %}

type Result<T> = std::result::Result<T, anyhow::Error>;

#[derive(Args, Debug)]
pub struct {{ noun | capitalize }}Cmd {
    #[command(subcommand)]
    pub verb: Verb,
}

#[derive(Subcommand, Debug)]
pub enum Verb {
{% for verb in verbs %}    /// {{ verb | capitalize }} a {{ noun }}
    ///
    /// Examples:
    ///   {{ project_name }} {{ noun }} {{ verb }}{% if verb == "get" or verb == "update" or verb == "delete" %} <id>{% endif %}
    {{ verb | capitalize }}({{ verb }}::{{ verb | capitalize }}Args),
{% endfor %}}

impl {{ noun | capitalize }}Cmd {
    pub async fn run(&self) -> Result<()> {
        match &self.verb {
{% for verb in verbs %}            Verb::{{ verb | capitalize }}(args) => {{ verb }}::run(args).await,
{% endfor %}        }
    }
}
