Skip to content

Commit

Permalink
0.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeterv committed Jun 20, 2015
1 parent 389d5e0 commit 75a7656
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 33 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,55 @@

[![Build Status](https://travis-ci.org/mpeterv/argparse.png?branch=master)](https://travis-ci.org/mpeterv/argparse)

argparse is a 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.

argparse supports positional arguments, options, flags, optional arguments, subcommands and more. argparse automatically generates usage, help and error messages.
Argparse supports positional arguments, options, flags, optional arguments, subcommands and more. Argparse automatically generates usage, help and error messages.

Quick glance:
Simple example:

```lua
-- script.lua
local argparse = require "argparse"
local parser = argparse()
:description "An example."
parser:argument "input"
:description "Input file."
parser:option "-o" "--output"
:default "a.out"
:description "Output file."
parser:option "-I" "--include"
:count "*"
:description "Include locations."

local parser = argparse("script", "An example.")
parser:argument("input", "Input file.")
parser:option("-o --output", "Output file.", "a.out")
parser:option("-I --include", "Include locations."):count("*")

local args = parser:parse()
prettyprint(args)
print(args) -- Assuming print is patched to handle tables nicely.
```

```bash
$ lua script.lua foo
```

```
input: foo
output: a.out
include: {}
```lua
{
input = "foo",
output = "a.out",
include = {}
}
```

```bash
$ lua script.lua foo -I/usr/local/include -I/src -o bar
$ lua script.lua foo -I/usr/local/include -Isrc -o bar
```

```
input: foo
output: bar
include: {/usr/local/include, /src}
```lua
{
input = "foo",
output = "bar",
include = {"/usr/local/include", "src"}
}
```

```bash
$ lua script.lua foo bar
```

```
Usage: script.lua [-o <output>] [-I <include>] [-h] <input>
Usage: script [-o <output>] [-I <include>] [-h] <input>
Error: too many arguments
```
Expand All @@ -60,7 +60,7 @@ $ lua script.lua --help
```

```
Usage: script.lua [-o <output>] [-I <include>] [-h] <input>
Usage: script [-o <output>] [-I <include>] [-h] <input>
An example.
Expand All @@ -80,7 +80,7 @@ $ lua script.lua foo --outptu=bar
```

```
Usage: script.lua [-o <output>] [-I <include>] [-h] <input>
Usage: script [-o <output>] [-I <include>] [-h] <input>
Error: unknown option '--outptu'
Did you mean '--output'?
Expand All @@ -95,26 +95,26 @@ Did you mean '--output'?

## Installation

### Using luarocks
### Using LuaRocks

Installing argparse using luarocks is simple.
Installing argparse using [LuaRocks](http://luarocks.org) is simple:

```bash
$ luarocks install argparse
```

### Without luarocks
### Without LuaRocks

Download `src/argparse.lua` file and put it into the directory for Lua libraries or your working directory.
Download `src/argparse.lua` file and put it into the directory for Lua libraries or your working directory.

## Tutorial

The tutorial is available [online](http://mpeterv.github.io/argparse/) and in the `doc` directory. If argparse was installed using luarocks 2.1.2 or later, it can be viewed using `luarocks doc argparse` command.
The tutorial is available [online](http://argparse.readthedocs.org) and in the `doc` directory. If argparse has been installed using LuaRocks 2.1.2 or later, it can be viewed using `luarocks doc argparse` command.

## Testing

argparse comes with a testing suite located in `spec` directory. [busted](http://olivinelabs.com/busted/) is required for testing, it can be installed using luarocks. Run the tests using `busted spec` command from the argparse folder.
argparse comes with a testing suite located in `spec` directory. [busted](http://olivinelabs.com/busted/) is required for testing, it can be installed using LuaRocks. Run the tests using `busted spec` command from the argparse folder.

## License

argparse is licensed under the same terms as Lua itself(MIT license).
argparse is licensed under the same terms as Lua itself (MIT license).
22 changes: 22 additions & 0 deletions rockspecs/argparse-0.4.0-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package = "argparse"
version = "0.4.0-1"
source = {
url = "git://github.com/mpeterv/argparse",
tag = "0.4.0"
}
description = {
summary = "A feature-rich command-line argument parser",
detailed = "Argparse supports positional arguments, options, flags, optional arguments, subcommands and more. Argparse automatically generates usage, help and error messages.",
homepage = "https://github.com/mpeterv/argparse",
license = "MIT/X11"
}
dependencies = {
"lua >= 5.1, < 5.4"
}
build = {
type = "builtin",
modules = {
argparse = "src/argparse.lua"
},
copy_directories = {"doc", "spec"}
}

0 comments on commit 75a7656

Please sign in to comment.