Crates.io | arg_fn |
lib.rs | arg_fn |
version | 1.0.0 |
source | src |
created_at | 2024-01-10 07:01:19.777982 |
updated_at | 2024-01-10 07:01:19.777982 |
description | Argument parsing with higher order functions |
homepage | https://github.com/Vonr/arg_fn |
repository | https://github.com/Vonr/arg_fn |
max_upload_size | |
id | 1094978 |
size | 4,912 |
Argument parsing crate that allows the user to specify what to do for each argument.
#[derive(PartialEq, Debug, Default)]
struct Config {
foo: bool,
bar: bool,
}
let cfg = arg_fn::Parser::new(Config::default(), |_cfg, _arg| {})
.arg("-foo", |cfg| cfg.foo = true)
.arg("-nofoo", |cfg| cfg.foo = false)
.arg("-bar", |cfg| cfg.bar = true)
.arg("-nobar", |cfg| cfg.bar = false)
.parse(["-bar", "-nofoo", "-foo", "-nobar", "-foo"]);
assert_eq!(
cfg,
Config {
foo: true,
bar: false,
}
)