ggen-cli-lib 26.7.3

CLI interface for ggen
Documentation
//! Domain logic for {{ module_name }}

use clap_noun_verb::Result;
use serde_json::{json, Value};

/// Execute {{ module_name }} business logic.
///
/// Returns a JSON value the CLI surface serializes via the requested `--format`.
/// Replace the echo below with the real implementation.
pub fn execute(
    {%- for argument in arguments %}
    {%- if argument.required %}
    {{ argument.name }}: {{ argument.type }},
    {%- else %}
    {{ argument.name }}: Option<{{ argument.type }}>,
    {%- endif %}
    {%- endfor %}
    {%- for flag in flags %}
    {{ flag.name }}: bool,
    {%- endfor %}
) -> Result<Value> {
    Ok(json!({
        "command": "{{ module_name }}",
        {%- for argument in arguments %}
        "{{ argument.name }}": format!("{:?}", {{ argument.name }}),
        {%- endfor %}
        {%- for flag in flags %}
        "{{ flag.name }}": {{ flag.name }},
        {%- endfor %}
    }))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_{{ module_name | snake }}_execute() {
        // Assert on the returned JSON `Value` once the real logic lands.
        let _ = stringify!(execute);
    }
}