minimal rust library to execute commands
Find a file
2026-02-28 10:55:54 -05:00
src fix my dumb spaghetti code 2026-02-28 10:55:54 -05:00
.gitignore initiliaze the rust project 2026-02-26 20:59:35 -05:00
Cargo.lock commit lock files 2026-02-26 21:31:27 -05:00
Cargo.toml add repo and bump verision number 2026-02-26 21:30:20 -05:00
LICENSE Initial commit 2026-02-27 01:57:56 +00:00
README.md add readme message 2026-02-27 16:16:13 -05:00

ommandz

Zero-dependency Rust library for executing shell commands. in 46kb. (34kb is the license)

Usage

Import the trait and call .exec() on any string:

use ommandz::CommandExt;

let output = "echo hello world".exec().unwrap();
println!("{}", output.stdout_str());

Or use the function directly:

use ommandz::exec;

let output = exec("echo hello world").unwrap();

API

String Extension

The CommandExt trait adds .exec() to str:

"command here".exec() -> Result<Output, Error>

Function

exec(cmd: &str) -> Result<Output, Error>

Output

  • stdout: Vec<u8> - Raw bytes
  • stderr: Vec<u8> - Raw bytes
  • status: ExitStatus - Exit status
  • stdout_str() - UTF-8 string
  • stderr_str() - UTF-8 string
  • success() - True if exit code 0

Error

  • EmptyCommand - Empty input
  • SpawnFailed(String) - Failed to run
  • IoError(String) - Read failed

Parsing

Handles shell-like syntax:

  • 'single quotes' - Literal
  • "double quotes" - Literal with escapes
  • \ - Escapes next char
  • Whitespace - Separates args
"sh -c 'echo hello && echo world'".exec()
"echo hello\\ world".exec()

made with ❤️ by landon