Skip to main content

command_stream/execa/
mod.rs

1//! Execa-style exact-argument process execution with a separate options store.
2//!
3//! Unlike the native shell API, these commands execute a file directly and
4//! reject failures by default. Output stays as bytes; `text()` and line helpers
5//! provide decoded views. JavaScript-specific IPC and transforms belong to the
6//! JavaScript `command-stream/execa` entry point.
7//!
8//! ```no_run
9//! # async fn example() -> Result<(), command_stream::execa::ExecaError> {
10//! let result = command_stream::execa("git", ["status", "--short"]).await?;
11//! println!("{}", result.text());
12//! # Ok(())
13//! # }
14//! ```
15
16mod command;
17mod options;
18mod process;
19mod result;
20
21pub use command::{Execa, ExecaCommand};
22pub use options::{CancelSignal, Cancellation, Options};
23pub use process::Subprocess;
24pub use result::{ExecaError, ExecaOutcome, ExecaResult};
25use std::ffi::OsString;
26
27pub fn execa<P, I, S>(file: P, args: I) -> ExecaCommand
28where
29    P: Into<OsString>,
30    I: IntoIterator<Item = S>,
31    S: Into<OsString>,
32{
33    Execa::default().command(file, args)
34}
35
36pub fn execa_sync<P, I, S>(file: P, args: I) -> ExecaOutcome
37where
38    P: Into<OsString>,
39    I: IntoIterator<Item = S>,
40    S: Into<OsString>,
41{
42    execa(file, args).sync()
43}
44
45pub fn execa_node<P, I, S>(file: P, args: I) -> ExecaCommand
46where
47    P: Into<OsString>,
48    I: IntoIterator<Item = S>,
49    S: Into<OsString>,
50{
51    Execa::default().node(file, args)
52}
53
54pub fn execa_compat(options: Options) -> Execa {
55    Execa::new(options)
56}