use governor_application::owners::{OwnersCheckInput, check};
use crate::cli::{OutputFormat, OwnersSubCommands};
use crate::error::{CommandExitCode, Result};
use crate::presenter::print_json;
use crate::runtime::{cargo_adapter, registry_adapter};
pub async fn check_cmd(
workspace_path: &str,
opts: &OwnersSubCommands,
_format: OutputFormat,
) -> Result<CommandExitCode> {
let all = match opts {
OwnersSubCommands::Check { all } => *all,
_ => false,
};
let started_at = std::time::Instant::now();
let cargo = cargo_adapter();
let registry = registry_adapter();
let output = check(
&cargo,
®istry,
OwnersCheckInput {
workspace_path: workspace_path.to_string(),
all,
},
)
.await?;
let workspace = output.workspace.clone();
let success = !output.drift_detected;
print_json(
"owners.check",
Some(workspace),
success,
output.clone(),
started_at,
Vec::new(),
)?;
Ok(if output.drift_detected {
CommandExitCode::DriftDetected
} else {
CommandExitCode::Success
})
}