Skip to content

dream-dasher/cargo-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cargo-Script

TLDR

#!/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

Ergonomics

  • 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
    • 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"]}
      ---

(see justfile groups for convenient access to both)

Links

Accessory Scripts

Convenience commands created for working with single scripts & directory. just-comms-cargo-scripts

(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.)

About

single-file rust scripts collection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published