21 releases

Uses new Rust 2021

0.2.2 Jun 8, 2022
0.2.1 Mar 16, 2022
0.1.17 Sep 4, 2021
0.1.14 May 29, 2021
0.1.6 Oct 19, 2020

#22 in Build Utils

Download history 7214/week @ 2022-03-09 8996/week @ 2022-03-16 7831/week @ 2022-03-23 8071/week @ 2022-03-30 6781/week @ 2022-04-06 6971/week @ 2022-04-13 7451/week @ 2022-04-20 7563/week @ 2022-04-27 7610/week @ 2022-05-04 9309/week @ 2022-05-11 9387/week @ 2022-05-18 9121/week @ 2022-05-25 10076/week @ 2022-06-01 10119/week @ 2022-06-08 10104/week @ 2022-06-15 9557/week @ 2022-06-22

41,396 downloads per month
Used in fewer than 10 crates

MIT/Apache

46KB
707 lines

xshell: Making Rust a Better Bash

xshell provides a set of cross-platform utilities for writing cross-platform and ergonomic "bash" scripts.

Example

//! 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 for more.

Dependencies