Crates.io | rusty-whsp |
lib.rs | rusty-whsp |
version | 0.1.6 |
source | src |
created_at | 2024-08-16 14:17:26.281789 |
updated_at | 2024-08-16 14:29:40.553059 |
description | A Rust library designed to handle configuration parsing for command-line applications |
homepage | https://rusty-libraries.github.io/rusty-whsp/#/ |
repository | https://github.com/rusty-libraries/rusty-whsp |
max_upload_size | |
id | 1340370 |
size | 20,489 |
A flexible and type-safe configuration parsing library for Rust command-line applications.
Add this to your Cargo.toml
:
[dependencies]
rusty-whsp = "0.1.6"
Here's a simple example to get you started:
use rusty_whsp::{Whsp, WhspOptions, ConfigOptionBase, ValidValue, Validator};
use std::collections::HashMap;
fn main() {
let mut whsp = Whsp {
config_set: HashMap::new(),
short_options: HashMap::new(),
options: WhspOptions {
allow_positionals: true,
env_prefix: Some("MYAPP".to_string()),
usage: None,
},
};
whsp.opt(HashMap::from([(
"config".to_string(),
ConfigOptionBase {
config_type: "string".to_string(),
short: Some("c".to_string()),
default: None,
description: Some("Configuration file path".to_string()),
validate: Some(Validator::None),
multiple: false,
},
)]));
let args: Vec<String> = std::env::args().collect();
let parsed_values = whsp.parse_raw(args[1..].to_vec());
println!("Parsed values: {:?}", parsed_values);
}
For detailed documentation, please refer to the Documentation file.
Check out the examples directory for more usage examples.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by rusty-libraries