use anyhow::Result;
use clap::{Args, Subcommand};
use ironflow_sdk::IronflowClient;
use crate::output;
#[derive(Debug, Args)]
pub struct WorkflowArgs {
#[command(subcommand)]
pub command: WorkflowCommands,
}
#[derive(Debug, Subcommand)]
pub enum WorkflowCommands {
List,
Get {
name: String,
},
}
pub async fn execute(client: &IronflowClient, args: &WorkflowArgs, json_mode: bool) -> Result<()> {
match &args.command {
WorkflowCommands::List => {
let response = client.list_workflows().await?;
output::print_output(json_mode, &response, || {
output::workflows_table(&response.data)
})?;
}
WorkflowCommands::Get { name } => {
let response = client.get_workflow(name).await?;
output::print_output(json_mode, &response, || {
output::workflow_detail_table(&response.data)
})?;
}
}
Ok(())
}