ironflow_engine/context/steps/shell.rs
1//! Shell step for [`WorkflowContext`].
2
3use ironflow_store::models::StepKind;
4
5use crate::config::{ShellConfig, StepConfig};
6use crate::context::WorkflowContext;
7use crate::error::EngineError;
8use crate::executor::StepOutput;
9
10impl WorkflowContext {
11 /// Execute a shell step.
12 ///
13 /// Creates the step record, runs the command, persists the result,
14 /// and returns the output for use in subsequent steps.
15 ///
16 /// # Errors
17 ///
18 /// Returns [`EngineError`] if the command fails or the store errors.
19 ///
20 /// # Examples
21 ///
22 /// ```no_run
23 /// use ironflow_engine::context::WorkflowContext;
24 /// use ironflow_engine::config::ShellConfig;
25 /// use ironflow_engine::error::EngineError;
26 ///
27 /// # async fn example(ctx: &mut WorkflowContext) -> Result<(), EngineError> {
28 /// let files = ctx.shell("list", ShellConfig::new("ls -la")).await?;
29 /// println!("stdout: {}", files.output["stdout"]);
30 /// # Ok(())
31 /// # }
32 /// ```
33 pub async fn shell(
34 &mut self,
35 name: &str,
36 config: ShellConfig,
37 ) -> Result<StepOutput, EngineError> {
38 self.execute_step(name, StepKind::Shell, StepConfig::Shell(config))
39 .await
40 }
41}