{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreiaopasq4gg2kb2kknbhk4euscec3sjrfzgbjqy2f4ed4shblhcbk4",
    "uri": "at://did:plc:tg3tb5wukiml4xmxml6qm637/app.bsky.feed.post/3mnr2gfymfz2k"
  },
  "canonicalUrl": "https://heaths.dev/rust/2026/06/08/cargo-scripts-are-also-manifests.html",
  "description": "Cargo scripts are single-file packages written in Rust. They are also valid Cargo manifests for built-in and popular commands like clippy.\n",
  "path": "/rust/2026/06/08/cargo-scripts-are-also-manifests.html",
  "publishedAt": "2026-06-08T05:35:02.000Z",
  "site": "at://did:plc:tg3tb5wukiml4xmxml6qm637/site.standard.publication/3meddhkrg5z2p",
  "tags": [
    "rust",
    "cargo",
    "clap",
    "tips"
  ],
  "textContent": "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.\n\nRecently, 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.\n\nCargo 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.\n\nYou can even run tests like shown in the example above:",
  "title": "Cargo scripts are also manifests"
}