# ⚙️ process-lib
Cross-platform, asynchronous Rust library to run commands in pipelines.
## Features
This library can be seen as a convenient async wrapper around `std::process::Command`:
- Wraps commands by default with `sh -c` or `cmd /C`
- Supports pipeline (previous command output sent as input for the next command)
- Exposes convenient functions to export output (as string lossy for example)
- Supports **tokio** and **async-std** async runtimes
- Supports **serde** (de)serialization
The library comes with 3 [cargo features](https://doc.rust-lang.org/cargo/reference/features.html), including 1 default one:
- **`tokio`**: enables the [tokio](https://crates.io/crates/tokio) async runtime
- `async-std`: enables the [async-std](https://crates.io/crates/async-std) async runtime
- `derive`: enables [serde](https://crates.io/crates/serde) support
## Example
```rust
use process::{Command, Pipeline};
#[tokio::main]
async fn main() {
// run a single command
let cmd = Command::new("echo hello, world!");
let out = cmd.run().await.unwrap().to_string_lossy();
assert_eq!(out, "hello, world!\n");
// run a pipeline
let cmd = Pipeline::new(["echo hello", "cat"]);
let out = cmd.run().await.unwrap().to_string_lossy();
assert_eq!(out, "hello\n");
}
```
*See the full API documentation on [docs.rs](https://docs.rs/process-lib/latest/process/).*
## Sponsoring
[](https://nlnet.nl/)
Special thanks to the [NLnet foundation](https://nlnet.nl/) and the [European Commission](https://www.ngi.eu/) that helped the project to receive financial support from various programs:
- [NGI Assure](https://nlnet.nl/project/Himalaya/) in 2022
- [NGI Zero Entrust](https://nlnet.nl/project/Pimalaya/) in 2023
- [NGI Zero Core](https://nlnet.nl/project/Pimalaya-PIM/) in 2024 *(still ongoing)*
If you appreciate the project, feel free to donate using one of the following providers:
[](https://github.com/sponsors/soywod)
[](https://ko-fi.com/soywod)
[](https://www.buymeacoffee.com/soywod)
[](https://liberapay.com/soywod)
[](https://thanks.dev/soywod)
[](https://www.paypal.com/paypalme/soywod)