Add safe file-root apply
This commit is contained in:
parent
bab13cc0a1
commit
5c91635ea2
8 changed files with 394 additions and 14 deletions
|
|
@ -300,6 +300,13 @@ pub enum CasRootCommand {
|
|||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
Apply {
|
||||
source: String,
|
||||
#[arg(long)]
|
||||
to: PathBuf,
|
||||
#[arg(long)]
|
||||
dry_run: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
|
|
@ -751,6 +758,15 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
name,
|
||||
bearer_secret,
|
||||
},
|
||||
CasRootCommand::Apply {
|
||||
source,
|
||||
to,
|
||||
dry_run,
|
||||
} => ControlRequest::CasRootApply {
|
||||
source,
|
||||
target: to,
|
||||
dry_run,
|
||||
},
|
||||
},
|
||||
CasCommand::Conflict { command } => match command {
|
||||
CasConflictCommand::Record {
|
||||
|
|
@ -1295,6 +1311,32 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
println!("reason: {reason}");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::CasRootApplied {
|
||||
source,
|
||||
target,
|
||||
files_written,
|
||||
dirs_created,
|
||||
conflicts,
|
||||
dry_run,
|
||||
note,
|
||||
} => {
|
||||
println!("applied file root: {source}");
|
||||
println!("target: {}", target.display());
|
||||
println!("dry_run: {dry_run}");
|
||||
println!("files_written: {files_written}");
|
||||
println!("dirs_created: {dirs_created}");
|
||||
println!("conflicts: {}", conflicts.len());
|
||||
for conflict in conflicts {
|
||||
println!(
|
||||
"{}\t{}\t{}\t{}",
|
||||
conflict.id,
|
||||
conflict.path,
|
||||
conflict.kind.as_str(),
|
||||
conflict.status.as_str()
|
||||
);
|
||||
}
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::CasConflictRecorded { conflict } => {
|
||||
println!("recorded conflict: {}", conflict.id);
|
||||
print_file_conflict(&conflict);
|
||||
|
|
|
|||
Loading…
Reference in a new issue