Cargo scripts are also manifests

Heath Stewart June 8, 2026
Source
I've been using cargo scripts for various tasks including in the Azure SDK for Rust. Shell scripts are versatile - and fast - but sometimes you just need the programmatic power and third-party crates that Rust gives you. Recently, I prototyped dynamic completion in clap using a cargo script for easily sharing as a gist, though that meant configuring the #\[command(name)] as the name of the source file e.g., dynamic.rs. Even though it compiles to dynamic, you run it as dynamic.rs which means shell completion has to match that name. Cargo scripts have evolved quite a bit since I started using them a couple years ago. cargo fmt works automatically when configured in editors like helix, but rust-analyzer support isn't complete yet making cargo clippy especially handy. Turns out, you can run clippy, cargo doc, and other commands using --manifest-path. You can even run tests like shown in the example above:

Discussion in the ATmosphere

Loading comments...