ucp 0.1.0

Collection of Useful CLI Parsers
Documentation
  • Coverage
  • 0%
    0 out of 14 items documented0 out of 0 items with examples
  • Size
  • Source code size: 23.52 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 852.48 kB 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
  • Kores/ucp
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JonathanxD

Useful CLI Parsers (UCP)

This crate provides a set of parsers for command line interfaces (CLI).

Examples

Nothing explains better than examples.

use ucp::pred::{Comparison, FieldComparison, Operator};

fn main() {
    assert_eq!(
        ">=1024".parse::<Comparison<usize>>(),
        Ok(Comparison::new(Operator::Gte, 1024))
    );

    assert_eq!(
        "!1024".parse::<Comparison<usize>>(),
        Ok(Comparison::new(Operator::Ne, 1024))
    );

    assert_eq!(
        "size=1024".parse::<FieldComparison<String, usize>>(),
        Ok(FieldComparison::new(
            String::from("size"),
            Operator::Eq,
            1024
        )),
    );

    assert_eq!(
        "size≠1024".parse::<FieldComparison<String, usize>>(),
        Ok(FieldComparison::new(
            String::from("size"),
            Operator::Ne,
            1024
        )),
    );
}

Note

I made this crate to simplify the process of making cli tools (which I do a lot for myself), it's intended to be used with clap and has no specialized Error type for parsing failures, String was used instead.

This may change in the next versions of the crate and will break compatibility with previous versions.