5 releases (1 stable)

Uses old Rust 2015

1.0.0 Sep 3, 2018
0.2.1 Feb 16, 2018
0.2.0 Feb 16, 2018
0.1.1 Feb 10, 2018
0.1.0 Feb 8, 2018

#795 in Command-line interface

MIT license

43KB
704 lines

Clargs is a library for parsing command-line arguments.

Parsing command-line arguments requires quite a bit of boilerplate code. This library remedies that for rust projects.

Before parsing an argument list a ParsingConfig object must be configured. It controls which features are enabled and how certain edge cases should be handled. It is also used to add flags, parameters, subcommands and specify which parameters are required and other extra info. Once configured, it can be used with the parse function.

A flag is an option that has a name and does not require an argument. A named parameter is an option that has a name and that does require an argument. An unnamed parameter is an option that is neither a flag, a named parameter, nor an argument to a named parameter. An alias maps one name to an option that already has another name.

Options are identified by the name they were registered with. Aliases are only used during interpretation of the command-line arguments. As a result of this, they will never occur in the results or an error after parsing.

All option names and aliases can contain only lower and uppercase letters and hyphens.

Note that the first argument is always interpreted as the name of the command (or subcommand) which was invoked.

No runtime deps