Expand description
Argument parsing and declaration using just the help text.
Since the help text is describing how a program can be run why not use that fact to have a zero-copy argument parsing solution? All one needs to do is write the help text and then send in the stream of arguments to the program to be auto-magically handled.
§Advantages
- No need to write your own parser.
- The help text’s format is up to the implementor as long they follow convention.
§Disadvantages
- No compile-time checking of the help text. Could lead to sneaky typos and other issues propping up. This could be alleviated by a proc-macro which does all the checks.
- No type inferance/conversion. Since, all arguments are
&str
(or rather[u8]
) there is no need to introduce extra complexity by allowing for conversion of arguments to a given type when that can be done by the user after parsing.
Notable other implementations:
docopt
- ‘official’ docopt implementation done by burntsushi. Is abandoned, uses too many dependencies, doesn’t take advantage of the fact that reallocations are unnecessary, parsing is dubiously implemented.lapp
- is not as complete asdocopt
§Features
std
- enabled XDG-compliance helper traits for structs that use serde
Structs§
- Docopt
- Parser of docopt.
- Settings
- A collection of parser settings that will adjust how the parser should parse certain elements.
Enums§
- Options
State - States of Options: parsing.
- Usage
State - Substates of Usage parsing.