homeboy 0.21.0

CLI for multi-component deployment and development workflow automation
Documentation
use clap::{Args, Subcommand};
use serde::Serialize;

use homeboy::release::{self, ReleasePlan, ReleaseRun};

use super::CmdResult;

#[derive(Args)]

pub struct ReleaseArgs {
    #[command(subcommand)]
    command: ReleaseCommand,
}

#[derive(Subcommand)]

enum ReleaseCommand {
    /// Plan a component release without executing steps
    Plan {
        /// Component ID to plan
        component_id: String,
    },
    /// Run a component release pipeline
    Run {
        /// Component ID to run
        component_id: String,
    },
}

#[derive(Serialize)]
#[serde(tag = "command")]

pub enum ReleaseOutput {
    #[serde(rename = "release.plan")]
    Plan { plan: ReleasePlan },
    #[serde(rename = "release.run")]
    Run { run: ReleaseRun },
}

pub fn run(args: ReleaseArgs, _global: &crate::commands::GlobalArgs) -> CmdResult<ReleaseOutput> {
    match args.command {
        ReleaseCommand::Plan { component_id } => {
            let plan = release::plan(&component_id, None)?;
            Ok((ReleaseOutput::Plan { plan }, 0))
        }
        ReleaseCommand::Run { component_id } => {
            let run = release::run(&component_id, None)?;
            Ok((ReleaseOutput::Run { run }, 0))
        }
    }
}