cargo-governor 2.0.3

Machine-First, LLM-Ready, CI/CD-Native release automation tool for Rust crates
Documentation
//! Plan command.

use governor_application::release::{PlanInput, plan};

use crate::cli::{OutputFormat, PlanOpts};
use crate::error::{CommandExitCode, Result};
use crate::presenter::print_json;
use crate::runtime::{cargo_adapter, git_adapter, registry_adapter};

pub async fn execute(
    workspace_path: &str,
    opts: PlanOpts,
    _format: OutputFormat,
) -> Result<CommandExitCode> {
    let started_at = std::time::Instant::now();
    let cargo = cargo_adapter();
    let git = git_adapter(workspace_path)?;
    let registry = registry_adapter();
    let output = plan(
        &cargo,
        &git,
        &registry,
        PlanInput {
            workspace_path: workspace_path.to_string(),
            include_published: opts.include_published,
            allow_version_drift: opts.allow_version_drift,
        },
    )
    .await?;
    let success = output.success;
    let workspace = output.workspace.clone();
    print_json(
        "release.plan",
        Some(workspace),
        success,
        output,
        started_at,
        Vec::new(),
    )?;
    Ok(if success {
        CommandExitCode::Success
    } else {
        CommandExitCode::GeneralError
    })
}