racker/luvit-options

Name: luvit-options

Owner: racker

Description: easy to use getopt library for luvit

Created: 2012-03-07 18:08:44.0

Updated: 2015-02-20 02:45:32.0

Pushed: 2015-02-20 02:45:32.0

Homepage:

Size: 106

Language: Lua

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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)

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.