Crates.io | script-meditate |
lib.rs | script-meditate |
version | 0.1.0 |
source | src |
created_at | 2024-07-07 15:34:30.91567 |
updated_at | 2024-07-07 15:34:30.91567 |
description | Supercharge Cargo scripts with inline structured data/configuration. |
homepage | |
repository | https://codeberg.org/dmb-ish/script-meditate |
max_upload_size | |
id | 1294958 |
size | 21,159 |
Supercharge Cargo scripts with inline structured data/configuration.
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,
}
The script must not be placed directly inside the user's home directory.
Copyright 2024 dmb-ish
Dual-licensed under MIT OR Apache-2.0.