feat: scripts can run from plan

This commit is contained in:
2025-02-28 22:08:56 +01:00
parent 2fadde0f8a
commit b0261de87e
3 changed files with 105 additions and 14 deletions

View File

@@ -18,10 +18,44 @@ impl ScriptExecutor {
}
pub async fn run(&self, script_ctx: &Script, name: &str) -> anyhow::Result<()> {
match script_ctx {
Script::Shell {} => ShellExecutor::from(self).execute(name).await?,
if self.run_project(script_ctx, name).await? {
return Ok(());
}
if self.run_plan(script_ctx, name).await? {
return Ok(());
}
Ok(())
}
async fn run_project(&self, script_ctx: &Script, name: &str) -> anyhow::Result<bool> {
match script_ctx {
Script::Shell {} => {
if matches!(
ShellExecutor::from(self).execute(name).await?,
shell::ScriptStatus::Found
) {
Ok(true)
} else {
Ok(false)
}
}
}
}
async fn run_plan(&self, script_ctx: &Script, name: &str) -> anyhow::Result<bool> {
match script_ctx {
Script::Shell {} => {
if matches!(
ShellExecutor::from_plan(self).execute(name).await?,
shell::ScriptStatus::Found
) {
Ok(true)
} else {
Ok(false)
}
}
}
}
}