feat: add local commands flow

This commit is contained in:
2026-08-22 19:37:16 +05:00
parent 1a332a6bb2
commit 1555f0434e
2 changed files with 146 additions and 11 deletions
+20 -11
View File
@@ -1,5 +1,6 @@
mod cli;
mod config;
mod local;
use std::process::ExitCode;
@@ -50,13 +51,18 @@ fn run(cli: &cli::Cli) -> Result<()> {
project.sync.len(),
project.remote.as_ref().map_or(0, |c| c.commands.len()),
);
let local_cmds = project
.local
.as_ref()
.map_or([].as_slice(), |c| c.commands.as_slice());
let remote_cmds = project
.remote
.as_ref()
.map_or([].as_slice(), |c| c.commands.as_slice());
if cli.dry_run {
println!("dry-run plan:");
for cmd in project
.local
.as_ref()
.map_or([].as_slice(), |c| c.commands.as_slice())
{
for cmd in local_cmds {
println!(" local : {cmd}");
}
for rule in &project.sync {
@@ -66,15 +72,18 @@ fn run(cli: &cli::Cli) -> Result<()> {
rule.target.display()
);
}
for cmd in project
.remote
.as_ref()
.map_or([].as_slice(), |c| c.commands.as_slice())
{
for cmd in remote_cmds {
println!(" remote: {cmd}");
}
} else {
println!("stage 2 not implemented yet: local command execution");
local::run_commands(local_cmds, &project.workdir)?;
println!("[Local] done: {} cmd(s) succeeded", local_cmds.len());
if !project.sync.is_empty() {
println!("stage 4 not implemented yet: SFTP file transfer");
}
if !remote_cmds.is_empty() {
println!("stage 3 not implemented yet: SSH remote execution");
}
}
Ok(())
}