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 {
component_id: String,
},
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))
}
}
}