rusty-whsp 0.1.7

A Rust library designed to handle configuration parsing for command-line applications
Documentation
  • Coverage
  • 0%
    0 out of 45 items documented0 out of 23 items with examples
  • Size
  • Source code size: 14.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.85 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • 24rr

rusty-whsp

Rust Crates.io Documentation License: MIT

A flexible and type-safe configuration parsing library for Rust command-line applications.

Table of Contents

Features

  • 🚀 Easy-to-use API for defining configuration options
  • 🔢 Support for string, number, and boolean option types
  • 📚 Single and multiple value options
  • ✅ Automatic input validation
  • 🌍 Default value setting from environment variables
  • 🔤 Short and long command-line option support

Installation

Add this to your Cargo.toml:

[dependencies]

rusty-whsp = "0.1.7"

Quick Start

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);
}

Documentation

For detailed documentation, please refer to the Documentation file.

Examples

Check out the examples directory for more usage examples.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by rusty-libraries