Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matklad/xshell
https://github.com/matklad/xshell
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/matklad/xshell
- Owner: matklad
- License: apache-2.0
- Created: 2020-10-15T22:52:14.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-07T16:05:27.000Z (3 months ago)
- Last Synced: 2024-09-19T06:40:22.369Z (about 2 months ago)
- Language: Rust
- Size: 184 KB
- Stars: 677
- Watchers: 12
- Forks: 28
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# xshell: Making Rust a Better Bash
`xshell` provides a set of cross-platform utilities for writing cross-platform
and ergonomic "bash" scripts.## Example
```rust
//! Clones a git repository and publishes it to crates.io.
use xshell::{cmd, Shell};fn main() -> anyhow::Result<()> {
let sh = Shell::new()?;let user = "matklad";
let repo = "xshell";
cmd!(sh, "git clone https://github.com/{user}/{repo}.git").run()?;
sh.change_dir(repo);let test_args = ["-Zunstable-options", "--report-time"];
cmd!(sh, "cargo test -- {test_args...}").run()?;let manifest = sh.read_file("Cargo.toml")?;
let version = manifest
.split_once("version = \"")
.and_then(|it| it.1.split_once('\"'))
.map(|it| it.0)
.ok_or_else(|| anyhow::format_err!("can't find version field in the manifest"))?;cmd!(sh, "git tag {version}").run()?;
let dry_run = if sh.var("CI").is_ok() { None } else { Some("--dry-run") };
cmd!(sh, "cargo publish {dry_run...}").run()?;Ok(())
}
```See [the docs](https://docs.rs/xshell) for more.
If you like the ideas behind xshell, you will enjoy [dax](https://github.com/dsherret/dax).