4 releases

0.1.3 Mar 27, 2020
0.1.2 Mar 27, 2020
0.1.1 Jan 24, 2020
0.1.0 Dec 28, 2019

#61 in #intended

MIT license

10KB
183 lines

ezflags

A simple to use API for command line flags in rust.

Modeled after golang's flag API, it allows for simple no-frills command line parsing.

It's designed to be simple, but doesn't offer the performance or all the features of clap. If you're looking for high performance, use clap. This is intended to be a library for building small command line utilities.

let mut fs = FlagSet::new();
let mut int_flag: Option<i32> = None;
fs.add("num", "Info about num", &mut int_flag);
// <Binary> -num 3
let _remaining_args = fs.parse_args();
assert_eq!(int_flag, Some(3));

It also offers a simple toggle:

let mut fs = FlagSet::new();
let mut switch = false;
fs.add("switch", "Pass this to set switch", &mut switch);
// <Binary> -switch
let _remaining_args = fs.parse_args();
assert_eq!(switch, true);

Help can be printed by passing the -h or --help flag to the binary, and it will list all the flags along with help info provided and exit.

Contributions

Any contributions welcome, just leave a pull request, and I will try to get to it.

No runtime deps