easy to use getopt library for luvit
Lua
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
modules/options
LICENSE
README.md
init.lua
package.lua
test.lua
test2.lua

README.md

luvit-options

This module implements an easy to use getopt library for luvit.

External links

luvit-options is inspired in node-optimist module

https://github.com/substack/node-optimist

Based on lua's getopt

http://lua-users.org/wiki/AlternativeGetOpt

Example

#!/usr/bin/env luvit

local opt = require ("options")
	:usage ("Usage: ./test.lua [-hk] [-a arg] [-b arg]")
	:default ("a", "patata")
	:describe ("a", "set an argument to this flag")
	:describe ("b", "set b flag")
	:describe ("k", "kakaka")
	:describe ("h", "showHelp")
	:alias ( {["a"]="arg"})
	:demand ({"a", "k"})
	:check(function(opt)
		return opt.b
	end)
	:argv ("ha:b:k")
p(opt)