27 releases

0.3.0-pre.2 Dec 23, 2024
0.2.7 Nov 16, 2024
0.2.6 Mar 28, 2024
0.2.5 Jul 11, 2023
0.1.6 Oct 19, 2020

#13 in Build Utils

Download history 62315/week @ 2024-09-21 55808/week @ 2024-09-28 63547/week @ 2024-10-05 65229/week @ 2024-10-12 62949/week @ 2024-10-19 61607/week @ 2024-10-26 63574/week @ 2024-11-02 61025/week @ 2024-11-09 69402/week @ 2024-11-16 65154/week @ 2024-11-23 81099/week @ 2024-11-30 85031/week @ 2024-12-07 76869/week @ 2024-12-14 36247/week @ 2024-12-21 47876/week @ 2024-12-28 64025/week @ 2025-01-04

237,725 downloads per month
Used in 150 crates (36 directly)

MIT/Apache

56KB
881 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_echo()?;
    sh.set_current_dir(repo);

    let test_args = ["-Zunstable-options", "--report-time"];
    cmd!(sh, "cargo test -- {test_args...}").run_echo()?;

    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_echo()?;

    let dry_run = if sh.var("CI").is_ok() { None } else { Some("--dry-run") };
    cmd!(sh, "cargo publish {dry_run...}").run_echo()?;

    Ok(())
}

See the docs for more.

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

Dependencies