script-meditate

Crates.ioscript-meditate
lib.rsscript-meditate
version0.1.0
sourcesrc
created_at2024-07-07 15:34:30.91567
updated_at2024-07-07 15:34:30.91567
descriptionSupercharge Cargo scripts with inline structured data/configuration.
homepage
repositoryhttps://codeberg.org/dmb-ish/script-meditate
max_upload_size
id1294958
size21,159
(dmb-ish)

documentation

README

script-meditate

crates.io

Supercharge Cargo scripts with inline structured data/configuration.

Example

Place the following in a file and make it executable, so it can be used as a standalone script:

#!/usr/bin/env -S cargo +nightly -Zscript
---cargo
[package]
edition = "2021"

[dependencies]
script-meditate = { version = "0.1.0", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
---
/*json
{
    "test": 42
}
*/

fn main() {
    let value: Data = script_meditate::extract_json_frontmatter!();
    dbg!(&value);
    assert_eq!(value.test, 42);
}

#[derive(Debug, serde::Deserialize)]
struct Data {
    test: u8,
}

Note

The script must not be placed directly inside the user's home directory.

License

Copyright 2024 dmb-ish

Dual-licensed under MIT OR Apache-2.0.

Commit count: 0

cargo fmt