Our great sponsors
-
Puts Debuggerer
Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.
-
rust-analyzer
Discontinued A Rust compiler front-end for IDEs [Moved to: https://github.com/rust-lang/rust-analyzer] (by rust-analyzer)
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
scriptisto
A language-agnostic "shebang interpreter" that enables you to write scripts in compiled languages.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
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(()) }
This is what we use in rust-analyzer for our copious build shenanigan (PR).
I.e. what stops me from making it run git clone https://github.com/rust-lang/rust; rm -rf /; echo you.git ?
I don't know if you've ever seen it before, but scriptisto does something similar to that. I've used it a wee bit, it's a fairly cool tool
I think there are some projects in this area, eg, https://github.com/DanielKeep/cargo-script. For my personal scripts, I have a single Cargo.toml for a busy-box style multiplexed binary: https://github.com/matklad/config/blob/f0259ca8a3755f2e62a3bf472c2514fd6cb891ff/tool/src/main.rs#L16.