.. | ||
tests | ||
args.py | ||
README.md |
A Simple and stupid Args Parser.
The subject was found here: https://codingdojo.org/kata/Args/
This implementation requires no dependencies (but probably comes with some bugs).
Defining the pattern
An arguments pattern is defined by a comma-separated expressions with the following format:
FLAG:NAME:TYPE[*]
FLAG
must be one character only, and is the token that should be encountered on the line to parse.NAME
is the argument name, and will be the name of the available matching property once the command line was parsed.TYPE
can be b for boolean, d for an integer (think C), s for a string. If the format is followed by a star, then the argument should be a comma-separated list of values with the given type.
The tests are full of samples.
Known limitations
- Pattern parsing is fragile, as it misses many tests on the input.
- Boolean arrays were not considered.
Tests
Unit tests for pytest and siblings are available in the tests
directory. Because of laziness and lack of time, they only examine the parse function as a black box.