Better Commands
This crate provides the ability to more easily run a [Command
] while also doing something with its output as it runs, as well as providing some extra functionality.
Why?
Rust's stock [Command
] kinda sucks, usually it only lets you get the output of a command with stdout and stderr completely separate. This crate lets you run code to handle the output as it prints, as well as providing all the lines together, with timestamps and which stream the line was printed to.
Features
- Specifies whether a [
Line
] is printed to stderr or stderr - Provides a timestamp for each [
Line
] - Provides timestamps for the command as a whole (start, end, and duration)
A basic example (see [run
]):
use run;
use Command;
let output = run;
println!;
A more complex example - this lets you provide a function to be run using the output from the command in real-time (see [run_funcs_with_lines
]):
use run_funcs_with_lines;
use Line;
use Command;
let cmd = run_funcs_with_lines;
// prints the following: [Line { printed_to: Stdout, time: Instant { tv_sec: 16316, tv_nsec: 283884648 }, content: "hi" }]
// (timestamp varies)
assert_eq!;