ironflow_cli/commands/
workflow.rs1use anyhow::Result;
4use clap::{Args, Subcommand};
5use ironflow_sdk::IronflowClient;
6
7use crate::output;
8
9#[derive(Debug, Args)]
11pub struct WorkflowArgs {
12 #[command(subcommand)]
14 pub command: WorkflowCommands,
15}
16
17#[derive(Debug, Subcommand)]
19pub enum WorkflowCommands {
20 List,
22 Get {
24 name: String,
26 },
27 Pause {
29 name: String,
31 },
32 Resume {
34 name: String,
36 },
37}
38
39pub async fn execute(client: &IronflowClient, args: &WorkflowArgs, json_mode: bool) -> Result<()> {
45 match &args.command {
46 WorkflowCommands::List => {
47 let response = client.list_workflows().await?;
48 output::print_output(json_mode, &response, || {
49 output::workflows_table(&response.data)
50 })?;
51 }
52 WorkflowCommands::Get { name } => {
53 let response = client.get_workflow(name).await?;
54 output::print_output(json_mode, &response, || {
55 output::workflow_detail_table(&response.data)
56 })?;
57 }
58 WorkflowCommands::Pause { name } => {
59 let response = client.pause_workflow(name).await?;
60 output::print_output(json_mode, &response, || {
61 output::workflow_pause_table(&response.data)
62 })?;
63 }
64 WorkflowCommands::Resume { name } => {
65 let response = client.resume_workflow(name).await?;
66 output::print_output(json_mode, &response, || {
67 output::workflow_pause_table(&response.data)
68 })?;
69 }
70 }
71 Ok(())
72}