#getopts #arg #builder #no-std

no-std getopts-macro

Using macros to concisely define the getopts

9 releases

new 0.1.8 Jun 15, 2025
0.1.7 Jun 15, 2025
0.1.3 May 2, 2025
0.1.2 Apr 4, 2025
0.1.1 Mar 15, 2025

#496 in Command-line interface

Download history 112/week @ 2025-03-09 131/week @ 2025-03-16 14/week @ 2025-03-23 126/week @ 2025-03-30 54/week @ 2025-04-06 8/week @ 2025-04-13 22/week @ 2025-04-20 109/week @ 2025-04-27 27/week @ 2025-05-04 25/week @ 2025-05-11 13/week @ 2025-05-18 108/week @ 2025-06-01 192/week @ 2025-06-08

319 downloads per month

MIT license

18KB
387 lines

Using macros to concisely define the getopts

use getopts_macro::getopts_options;

let _options = getopts_options! {
    -z --zero           "...";
    -v --verbose*       "...";
    -T --threads=NUM    "...";
    -i --ignore*=FILE   "...";
    -h --help*          "...";
    -V --version*       "...";
};

Expand to:

let _options = {
    let mut options = getopts::Options::new();
    options.optflag("z", "zero", "...");
    options.optflagmulti("v", "verbose", "...");
    options.optopt("T", "threads", "...", "NUM");
    options.optmulti("i", "ignore", "...", "FILE");
    options.optflagmulti("h", "help", "...");
    options.optflagmulti("V", "version", "...");
    options
};

Dependencies

~1.5MB
~24K SLoC