greentic-flow-builder 0.1.0

AI-powered Adaptive Card flow builder with visual graph editor and demo runner
Documentation
use std::path::PathBuf;

use clap::{Args, Parser, Subcommand};

#[derive(Parser)]
#[command(name = "greentic-flow-builder")]
#[command(version)]
#[command(about = "AI-powered Adaptive Card flow builder with visual graph editor", long_about = None)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Render data into an Adaptive Card using a template/preset.
    Render(RenderArgs),
    /// List available presets grouped by category.
    List(ListArgs),
    /// Print the JSON Schema for a preset's expected data.
    Schema(SchemaArgs),
    /// Validate data against a preset's schema without rendering.
    Validate(ValidateArgs),
    /// Launch the web UI with LLM-powered card generation.
    Ui(UiArgs),
}

#[derive(Args, Debug)]
pub struct RenderArgs {
    /// Preset name (e.g., "menu-card").
    #[arg(short, long)]
    pub preset: Option<String>,

    /// Legacy alias for --preset.
    #[arg(long, hide = true)]
    pub template: Option<String>,

    /// Theme name (default: "default").
    #[arg(long)]
    pub theme: Option<String>,

    /// JSON data file path, or "-" for stdin.
    #[arg(short, long)]
    pub data: Option<PathBuf>,

    /// Inline JSON data string.
    #[arg(long)]
    pub data_json: Option<String>,

    /// Output file path (default: stdout).
    #[arg(short, long)]
    pub output: Option<PathBuf>,

    /// External template pack (path or URL). Can be specified multiple times.
    #[arg(long = "template-pack")]
    pub template_pack: Vec<PathBuf>,

    /// Fail on missing data fields instead of using empty defaults.
    #[arg(long)]
    pub strict: bool,

    /// Output compact JSON instead of pretty-printed.
    #[arg(long)]
    pub compact: bool,
}

#[derive(Args, Debug)]
pub struct ListArgs {
    /// Filter by category.
    #[arg(short, long)]
    pub category: Option<String>,

    /// Output as JSON array.
    #[arg(long)]
    pub json: bool,

    /// External template pack (path or URL).
    #[arg(long = "template-pack")]
    pub template_pack: Vec<PathBuf>,
}

#[derive(Args, Debug)]
pub struct SchemaArgs {
    /// Preset name.
    #[arg(short, long)]
    pub template: String,

    /// External template pack (path or URL).
    #[arg(long = "template-pack")]
    pub template_pack: Vec<PathBuf>,
}

#[derive(Args, Debug)]
pub struct ValidateArgs {
    /// Preset name.
    #[arg(short, long)]
    pub template: String,

    /// JSON data file path, or "-" for stdin.
    #[arg(short, long)]
    pub data: Option<PathBuf>,

    /// Inline JSON data string.
    #[arg(long)]
    pub data_json: Option<String>,

    /// External template pack (path or URL).
    #[arg(long = "template-pack")]
    pub template_pack: Vec<PathBuf>,
}

#[derive(Args, Debug)]
pub struct UiArgs {
    /// OpenAI API key for LLM-powered card generation.
    #[arg(long, env = "OPENAI_API_KEY")]
    pub openai_api_key: String,

    /// Port to listen on (default: random available port).
    #[arg(long)]
    pub port: Option<u16>,

    /// OpenAI model to use.
    #[arg(long, default_value = "gpt-4o-mini")]
    pub model: String,

    /// External template pack (path or URL). Can be specified multiple times.
    #[arg(long = "template-pack")]
    pub template_pack: Vec<PathBuf>,
}