25个发布版本

0.2.6 2024年3月28日
0.2.5 2023年7月11日
0.2.3 2022年12月14日
0.2.2 2022年6月8日
0.1.6 2020年10月19日

1455过程宏

Download history 51966/week @ 2024-03-14 50971/week @ 2024-03-21 46925/week @ 2024-03-28 53474/week @ 2024-04-04 56022/week @ 2024-04-11 62911/week @ 2024-04-18 65999/week @ 2024-04-25 70908/week @ 2024-05-02 63612/week @ 2024-05-09 68365/week @ 2024-05-16 67970/week @ 2024-05-23 71868/week @ 2024-05-30 66292/week @ 2024-06-06 70339/week @ 2024-06-13 75102/week @ 2024-06-20 63401/week @ 2024-06-27

每月 288,834 次下载
用于 121 个crate(通过 xshell

MIT/Apache

8KB
194

xshell:让Rust成为更好的Bash

xshell 提供了一组跨平台的工具,用于编写跨平台且易于使用的“bash”脚本。

示例

//! 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(())
}

更多信息请参见 文档

如果你喜欢xshell背后的想法,你将喜欢 dax


lib.rs:

xshell 的私有实现细节。

无运行时依赖