Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tcr/commandspec
Rust macro to build std::process::Command objects with shell syntax. Uses macro_rules! and works on stable.
https://github.com/tcr/commandspec
command macro process rust shell
Last synced: 20 days ago
JSON representation
Rust macro to build std::process::Command objects with shell syntax. Uses macro_rules! and works on stable.
- Host: GitHub
- URL: https://github.com/tcr/commandspec
- Owner: tcr
- Created: 2018-03-07T04:41:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-12T17:52:04.000Z (over 4 years ago)
- Last Synced: 2024-04-11T03:49:18.841Z (7 months ago)
- Topics: command, macro, process, rust, shell
- Language: Rust
- Homepage: http://docs.rs/commandspec
- Size: 26.4 KB
- Stars: 42
- Watchers: 3
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# commandspec
Simple Rust macro for building `std::process::Command` objects. Uses macro_rules! and works on stable.
```toml
[dependencies]
commandspec = "0.10"
```Then:
```rust
#[macro_use]
extern crate commandspec;use commandspec::CommandSpec; // .execute() method on Command
use std::process::Command;let result = execute!(
r"
cd path/location
export RUST_LOG=full
export RUST_BACKTRACE=1
cargo run {release_flag} --bin {bin_name} -- {args}
",
release_flag=Some("--release"),
bin_name="binary",
args=vec!["arg1", "arg2"],
)?;
// result = Ok(()) on success (error code 0), Err(CommandError) for all else
```Format of the commandspec input, in order:
* (optional) `cd ` to set the current working directory of the command, where path can be a literal, a quoted string, or format variable.
* (optional) one or more `export =` lines to set environment variables, with the same formatting options.
* Last, a command you want to invoke, optionally with format arguments.### Features:
* format-like invocation makes it easy to interpolate variables, with automatic quoting
* Equivalent syntax to shell when prototyping
* Works on stable Rust.## License
MIT or Apache-2.0, at your option.