shell
This package lets Cairo code spawn a command on the host machine and capture its standard
output. It uses the
shell
oracleprotocol. Each call is a
one‑shot subprocess: no processes are kept alive between invocations. The standard error is
routed to executor's log stream.
The command line is parsed and executed by a minimal cross-platform shell, the same that powers deno tasks.
Use it primarily in tests, prototypes, or local development scenarios where you need to call small utilities, format data, or fetch information that would be cumbersome to embed in Cairo directly.
Fully qualified path: shell
Free functions
exec | Executes a shell command and returns its exit code and standard output. Prefer using output if you only care about successful commands and want an error otherwise.... |
output | Runs a shell command and returns its stdout on success. If the underlying command exits with a non‑zero status, an error is returned which message includes the exit code.... |
Type aliases
ExitCode | Exit status returned by a shell command. |
Stdout | Captured standard output ( stdout ) of a shell command. |
Result | Result type re‑export for convenience. |
Free functions
exec | Executes a shell command and returns its exit code and standard output. Prefer using output if you only care about successful commands and want an error otherwise.... |
output | Runs a shell command and returns its stdout on success. If the underlying command exits with a non‑zero status, an error is returned which message includes the exit code.... |
exec
Executes a shell command and returns its exit code and standard output.
Prefer using output
if you only care about successful commands and want an error otherwise.
let (code, out) = shell::exec("echo Cairo").unwrap();
assert_eq!(code, 0);
assert_eq!(out, "Cairo\n");
Fully qualified path: shell::exec
pub fn exec(command: ByteArray) -> Result<(i32, ByteArray), Error>
output
Runs a shell command and returns its stdout
on success.
If the underlying command exits with a non‑zero status, an error is returned which message includes the exit code.
let uname = shell::output("uname -s").unwrap();
assert!(uname.len() > 0);
let result = shell::output("false");
assert!(result.is_err());
Fully qualified path: shell::output
pub fn output(command: ByteArray) -> Result<ByteArray, Error>
Type aliases
ExitCode | Exit status returned by a shell command. |
Stdout | Captured standard output ( stdout ) of a shell command. |
Result | Result type re‑export for convenience. |
ExitCode
Exit status returned by a shell command.
Fully qualified path: shell::ExitCode
pub type ExitCode = i32;
Stdout
Captured standard output (stdout
) of a shell command.
Fully qualified path: shell::Stdout
pub type Stdout = ByteArray;
Result
Result type re‑export for convenience.
Fully qualified path: shell::Result
pub type Result<T> = Result<T, Error>;