#!/usr/bin/env -S cargo +nightly -Zscript
---
[dependencies]
dep = { version = "x.y.z", features = ["f1", "f2"] }
---
//! # comments
//then just regular rust
- run directly
-
chmod u+x {{script_name}}.rs ./{{script_name}}.rs
-
- run via cargo
-
cargo +nightly -Zsscript {{sd_me: script_name}}.rs
-
- run other commands on script
-
cargo +nightly COMMAND *ARGS --manifest-path {{script_name}}.rs -Zscript
- e.g.
-
cargo +nightly add derive_more --manifest-path some-script.rs -Zscript
-
watchexec
allows diagnostic to be easily run while waiting on rust-analyzer support.- e.g.
-
watchexec --filter {{file}} 'clear; ./{{file}}'
- Compilation specs can be added in header.
- Currently prefer: modifying debug mode runtime.
- alternate: modify shebang line to force release or adjust flags to cargo
- less discoverable; and complicates non-run actions that aren't reading from sheband line
- alternate: modify shebang line to force release or adjust flags to cargo
- e.g.
-
--- package.edition = "2024" profile.dev.opt-level = 2 profile.dev.package."*".opt-level = 2 [dependencies] egui = "0.30.0" eframe = {version="0.30.0", default-features=false, features=["glow", "wayland"]} ---
- Currently prefer: modifying debug mode runtime.
(see justfile groups for convenient access to both)
- Cargo book: Script
- cargo-script tracking issue
- cargo-script + rustfmt tracking issue
- cargo-script + rust-analyzer tracking issue
Convenience commands created for working with single scripts & directory.
(Test & utility files for this accessory code are grouped under 'meta-tests'. These help check that no template text is miset and that compilation style checks output a partition of appropriate files.)