shell 1.0.0
An oracle that executes shell commands on the local machine
This library provides an interface for executing shell commands from Cairo scripts using the
shell
oracle protocol.
[dependencies]
shell = "1.0.0"
Language support: requires Cairo 2.13+
This package lets Cairo code spawn a command on the host machine and capture its standard output. 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.
#[executable]
fn main() {
let (code, stdout) = shell::exec("echo hello").unwrap();
assert_eq!(code, 0);
assert_eq!(stdout, "hello\n");
}
#[executable]
fn main() {
let os = shell::output("uname -s").unwrap();
assert!(os.len() > 0);
// Will return an oracle::Error because the command exits with code 1.
let err = shell::output("false");
assert!(err.is_err());
}
Version 1.0.0
Uploaded 1 week ago
License MIT
Cairo version ^2.12.3
Size 2.4 KB
Run the following command in your project dir
scarb add shell@1.0.0
Or add the following line to your Scarb.toml
shell = "1.0.0"