Crates.io | arg-kit |
lib.rs | arg-kit |
version | 1.0.1 |
source | src |
created_at | 2024-08-04 08:27:07.876051 |
updated_at | 2024-08-04 08:39:27.133676 |
description | A featherweight toolkit to help iterate long/short arguments |
homepage | |
repository | http://64-tesseract.us.to/projects#arg-kit |
max_upload_size | |
id | 1324811 |
size | 22,990 |
arg-kit is a featherweight library that helps parse arguments using one of
Rust's most versatile and powerful syntaxes: match {}
Do you really need bloated proc macros when collecting arguments can be
simplified to a .next()
? You have zero indication of what's going on under the
hood, so you can't implement your own behaviour.
That is why I don't call it an "argument parser" on its own. Your program parses the arguments, this just helps iterate over it, like so:
let mut argv = std::env::args();
for_args!(argv; {
arg!(-h | --help) => eprintln!("{HELP_TEXT}"),
arg!(-v | --value) => do_something(argv.next()?),
unknown => panic!("Unknown argument {unknown}"),
});
...which expands to:
let mut argv = std::env::args();
while let Some(args) = argv.next() {
for arg in args.as_arg() {
match arg {
...
Take a look through the docs for specific details. The sauce is hosted on my website because GitHub is gay.