From 66ab7b1076b2c5299cde7a6224cde5303c2af1c9 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sun, 19 Jan 2014 16:46:35 +0400 Subject: [PATCH] updated README.md [ci skip] --- README.md | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 01902e6..58e7f2d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,45 @@ -argparse -========= +# argparse [![Build Status](https://travis-ci.org/mpeterv/argparse.png?branch=master)](https://travis-ci.org/mpeterv/argparse) -Feature-rich command line parser for Lua inspired by argparse for Python. +__argparse__ is a feature-rich command line parser for Lua inspired by argparse for Python. -WIP. +Not everything stated here is implemented. -TODO -==== +Features: -* Add choices, converters. -* Write tests related to declarative interface. -* Write more tests related to parsing. -* Write tests related to commands. -* Implement automated help and usage message generation. -* Improve error messages. -* Suggestions for command typos. E.g. `$ luarocks isntall` -> `Did you mean 'install'?`. +* Parses: + * Short options(e.g. `-q`); + * Combined short options(e.g. `-zx`); + * Short options combined with arguments(e.g. `-I/usr/local/include`); + * Long options(e.g. `--quiet`); + * Long options with arguments(e.g. `--from there); + * GNU-style long options with arguments(e.g. `--from=there`). +* Supports named arguments consuming several arguments. +* Supports options and flags which can be invoked several times, consuming several arguments. + + Example: + + ```lua + parser:option "-p" "--pair" { + count = "*", + args = 2 + } + + parser:flag "-v" "--verbose" { + count = "*" + } + + local args = parser:parse{"--pair", "Alice", "Bob", "-p", "Emma", "John", "-vvv"} + -- args = { + -- pair = { + -- {"Alice", "Bob"}, + -- {"Emma", "John"} + -- }, + -- verbose = 3 + -- } + ``` + +* Supports default values and automatic conversions for arguments. +* [___NYI___] Automatically generates error, help and usage messages. +* Supports commands(e.g. in [git](http://git-scm.com/) CLI `add`, `commit`, `push`, etc. are commands). Each command has its own set of options and arguments.