26 releases

new 0.2.7 Nov 16, 2024
0.2.6 Mar 28, 2024
0.2.5 Jul 11, 2023
0.2.3 Dec 14, 2022
0.1.6 Oct 19, 2020

#1055 in Procedural macros

Download history 65931/week @ 2024-07-30 62443/week @ 2024-08-06 59348/week @ 2024-08-13 61319/week @ 2024-08-20 54881/week @ 2024-08-27 63304/week @ 2024-09-03 53531/week @ 2024-09-10 55445/week @ 2024-09-17 60719/week @ 2024-09-24 58953/week @ 2024-10-01 60320/week @ 2024-10-08 66834/week @ 2024-10-15 63241/week @ 2024-10-22 61233/week @ 2024-10-29 62040/week @ 2024-11-05 64345/week @ 2024-11-12

264,050 downloads per month
Used in 136 crates (via xshell)

MIT/Apache

8KB
194 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.


lib.rs:

Private implementation details of xshell.

No runtime deps