mars_agents/cli/
override_cmd.rs1use crate::error::MarsError;
4use crate::sync::{ConfigMutation, ResolutionMode, SyncOptions, SyncRequest};
5use crate::types::SourceName;
6
7use super::output;
8
9#[derive(Debug, clap::Args)]
11pub struct OverrideArgs {
12 pub source: String,
14
15 #[arg(long)]
17 pub path: std::path::PathBuf,
18}
19
20pub fn run(args: &OverrideArgs, ctx: &super::MarsContext, json: bool) -> Result<i32, MarsError> {
22 let request = SyncRequest {
23 resolution: ResolutionMode::Normal,
24 mutation: Some(ConfigMutation::SetOverride {
25 source_name: SourceName::from(args.source.as_str()),
26 local_path: args.path.clone(),
27 }),
28 options: SyncOptions::default(),
29 };
30 let report = crate::sync::execute(ctx, &request)?;
31
32 if !json {
33 output::print_success(&format!(
34 "override `{}` → {}",
35 args.source,
36 args.path.display()
37 ));
38 }
39 output::print_sync_report(&report, json, true);
40
41 if report.has_conflicts() { Ok(1) } else { Ok(0) }
42}