25 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

#1239 in Procedural macros

Download history 42273/week @ 2024-01-27 48134/week @ 2024-02-03 50150/week @ 2024-02-10 46608/week @ 2024-02-17 46731/week @ 2024-02-24 48910/week @ 2024-03-02 50716/week @ 2024-03-09 50046/week @ 2024-03-16 49395/week @ 2024-03-23 50581/week @ 2024-03-30 53425/week @ 2024-04-06 56455/week @ 2024-04-13 64467/week @ 2024-04-20 72974/week @ 2024-04-27 64626/week @ 2024-05-04 56089/week @ 2024-05-11

266,837 downloads per month
Used in 113 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