use governor_application::owners::{OwnersSyncInput, sync};
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 sync_cmd(
workspace_path: &str,
opts: &OwnersSubCommands,
_format: OutputFormat,
) -> Result<CommandExitCode> {
let (all, dry_run) = match opts {
OwnersSubCommands::Sync { all, dry_run } => (*all, *dry_run),
_ => (false, false),
};
let started_at = std::time::Instant::now();
let cargo = cargo_adapter();
let registry = registry_adapter();
let output = sync(
&cargo,
®istry,
OwnersSyncInput {
workspace_path: workspace_path.to_string(),
all,
dry_run,
},
)
.await?;
let workspace = output.workspace.clone();
let success = !output.partial_success;
print_json(
"owners.sync",
Some(workspace),
success,
output.clone(),
started_at,
Vec::new(),
)?;
Ok(if output.partial_success {
CommandExitCode::PartialSuccess
} else {
CommandExitCode::Success
})
}