24 releases

0.2.6 Mar 28, 2024
0.2.5 Jul 11, 2023
0.2.3 Dec 14, 2022
0.2.2 Jun 8, 2022
0.1.6 Oct 19, 2020

#11 in Build Utils

Download history 62758/week @ 2024-07-08 62604/week @ 2024-07-15 65178/week @ 2024-07-22 64202/week @ 2024-07-29 62099/week @ 2024-08-05 60620/week @ 2024-08-12 62739/week @ 2024-08-19 56809/week @ 2024-08-26 60438/week @ 2024-09-02 53974/week @ 2024-09-09 54623/week @ 2024-09-16 61405/week @ 2024-09-23 56123/week @ 2024-09-30 63525/week @ 2024-10-07 65106/week @ 2024-10-14 59898/week @ 2024-10-21

247,734 downloads per month
Used in 134 crates (34 directly)

MIT/Apache

48KB
716 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.

If you like the ideas behind xshell, you will enjoy dax.

Dependencies