6 releases

0.5.6 Dec 13, 2020
0.5.5 Oct 20, 2020
0.5.4 Aug 18, 2020
0.5.0 Jun 10, 2020

#965 in Command-line interface


Used in 2 crates

0BSD license

51KB
1.5K SLoC

This command line parser is based on a C++ command line parser which is based on a C command line parser which in turn was inspired by the Python argparse module.

The basic use pattern for qargparser is:

  1. Create a context struct for storing parser output.
  2. Create one or more Builder.
  3. Create Spec objects from the Builder objects by calling Builder::build(), passing a function for processing the option/argument.
  4. Create a Parser object (Parser::from_env() or Parser::from_args()) handing over the ownership of a parser context struct.
  5. Add the Spec objects to the parser object using Parser::add().
  6. Call the parser.
  7. At this point, if successful, the parser context should be populated with data from the command line. Call Parser::into_ctx() to regain ownership of the context.

One of the minor goals of qargparser is to simplify reuse of option/argument specs between parsers.

ToDo

  • Currently converts argument strings to UTF-8. Should support OsStr(ing).

Dependencies

~225KB