diff --git a/crates/axl-runtime/src/engine/std/process.rs b/crates/axl-runtime/src/engine/std/process.rs index 792b1c8e3..3160ad045 100644 --- a/crates/axl-runtime/src/engine/std/process.rs +++ b/crates/axl-runtime/src/engine/std/process.rs @@ -178,6 +178,9 @@ pub(crate) fn command_methods(registry: &mut MethodsBuilder) { Ok(this) } + /// Executes the command as a child process, returning a handle to it. + /// + /// By default, stdin, stdout and stderr are inherited from the parent. fn spawn<'v>(#[allow(unused)] this: values::Value<'v>) -> anyhow::Result { let cmd = this.downcast_ref_err::()?; let child = cmd.inner.borrow_mut().spawn()?; @@ -185,6 +188,17 @@ pub(crate) fn command_methods(registry: &mut MethodsBuilder) { inner: Rc::new(RefCell::new(Some(child))), }) } + + /// Executes a command as a child process, waiting for it to finish and collecting its status. + /// Unlike `cmd.spawn().wait()` and `cmd.spawn().wait_with_output()`, this function does not + /// close the stdin handle. + /// + /// By default, stdin, stdout and stderr are inherited from the parent. + fn status<'v>(#[allow(unused)] this: values::Value<'v>) -> anyhow::Result { + let cmd = this.downcast_ref_err::()?; + let status = cmd.inner.borrow_mut().status()?; + Ok(ExitStatus(status)) + } } #[derive(Debug, Display, Trace, ProvidesStaticType, NoSerialize, Allocative)] diff --git a/docs/lib/std/process/command.md b/docs/lib/std/process/command.md index 51634a0fc..0fb542c11 100644 --- a/docs/lib/std/process/command.md +++ b/docs/lib/std/process/command.md @@ -33,6 +33,21 @@
def Command.spawn(
 ) -> 'std.process.Child'
+Executes the command as a child process, returning a handle to it. + +By default, stdin, stdout and stderr are inherited from the parent. + +*** + +## Command.status + +
def Command.status(
+) -> 'std.process.ExitStatus'
+ +Executes a command as a child process, waiting for it to finish and collecting its status. Unlike `cmd.spawn().wait()` and `cmd.spawn().wait_with_output()`, this function does not close the stdin handle. + +By default, stdin, stdout and stderr are inherited from the parent. + *** ## Command.stderr