| Crates.io | ucp |
| lib.rs | ucp |
| version | 0.1.0 |
| created_at | 2024-02-26 04:33:13.810962+00 |
| updated_at | 2024-02-26 04:33:13.810962+00 |
| description | Collection of Useful CLI Parsers |
| homepage | https://gitlab.com/Kores/ucp |
| repository | https://gitlab.com/Kores/ucp |
| max_upload_size | |
| id | 1153011 |
| size | 23,521 |
This crate provides a set of parsers for command line interfaces (CLI).
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
)),
);
}
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.