Crates.io | rusty-pkl |
lib.rs | rusty-pkl |
version | 0.1.2 |
source | src |
created_at | 2024-02-11 23:22:02.149405 |
updated_at | 2024-02-11 23:29:05.02772 |
description | Lightweight Pkl parser for Rust |
homepage | |
repository | https://github.com/ladroid/pkl-rs |
max_upload_size | |
id | 1136172 |
size | 11,251 |
rusty-pkl is a Rust library for parsing Pkl configuration files. Pkl is a simple configuration language that supports hierarchical structures and various data types.
Clone this repository to your local machine
Navigate to the project directory:
Run the parser with the desired Pkl file:
cargo run --example test.rs
Suppose you have a Pkl file named example.pkl
with the following content:
name = "Pkl: Configure your Systems in New Ways"
attendants = 100
isInteractive = true
amountLearned = 13.37
bird {
name = "Common wood pigeon"
diet = "Seeds"
taxonomy {
species = "Columba palumbus"
}
}
Running the parser with this file will produce structured output representing the parsed Pkl values.
You can also access specific parameters programmatically and assign them to variables using the provided functions in the library. For example, to access the name
parameter:
use pkl_rs::*;
fn main() {
match parse_pkl("examples\\config.pkl") {
Ok(pkl_value) => {
println!("Parsed Pkl value: {:?}", pkl_value);
// You can further process the parsed Pkl value as needed
if let Some(value) = find_parameter(&pkl_value, "name") {
println!("Found name parameter: {:?}", value);
} else {
println!("Parameter 'name' not found.");
}
}
Err(err) => {
eprintln!("Error parsing Pkl file: {}", err);
}
}
}
Contributions are absolutely, positively welcome and encouraged! Contributions come in many forms. You could:
This project is licensed under the MIT License - see the LICENSE file for details.