duct.rs

Duct is a library for running child processes. Duct makes it easy to build pipelines and redirect IO like a shell. At the same time, Duct helps you write correct, portable code: whitespace is never significant, errors from child processes get reported by default, and a variety of gotchas, bugs, and platform inconsistencies are handled for you the Right Way™.
Changelog
- v0.13.1
- Added
ReaderHandle::kill. - Kill methods no longer wait on IO threads to complete. This avoids blocking on unkilled grandchildren.
- Added
- v0.13.0
- Removed the
thenmethod. - Added
ReaderHandleandExpression::reader. - Added
Expression::stdout_stderr_swap. - Renamed
stdin/stdout/stderrtostdin_path/stdout_path/stderr_path. - Renamed
stdin_handle/stdout_handle/stderr_handletostdin_file/stdout_file/stderr_file. - Renamed
inputtostdin_bytes. - Renamed
Handle::outputtoHandle::into_output.
- Removed the
Examples
Run a command without capturing any output. Here "hi" is printed directly to the terminal:
use cmd;
cmd!.run?;
Capture the standard output of a command. Here "hi" is returned as a
String:
let stdout = cmd!.read?;
assert_eq!;
Capture the standard output of a pipeline:
let stdout = cmd!.pipe.read?;
assert_eq!;
Merge standard error into standard output and read both incrementally:
use cmd;
use *;
use BufReader;
let big_cmd = cmd!;
let reader = big_cmd.stderr_to_stdout.reader?;
let mut lines = new.lines;
assert_eq!;
assert_eq!;
Children that exit with a non-zero status return an error by default:
let result = cmd!.run;
assert!;