GithubHelp home page GithubHelp logo

gonzalezjo / lgetopt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daelvn/lgetopt

0.0 1.0 0.0 38 KB

Getopt module for Lua.

Home Page: http://lgetopt.daelvn.ga

License: MIT License

Lua 64.79% MoonScript 35.21%

lgetopt's Introduction

lgetopt

lgetopt is a fork of bcnjr5/lua-getopt with slight changes to the code. It's a command-line argument parser for Lua 5.3.

Features

  • GNU-style flag handling (-rsv -> -r -s -v), but only for flags that don't accept values
  • D-style option definitions (more or less)

Usage

You can require the module which will return a function. The function takes the first argument as the list of arguments and the second as the option definitions.

local getopt = require "getopt"
getopt (arg, {})

Documentation

You can find the documentation for the function here

Changelog

v1.2.2 - 3 Jun 2018

Improved the help flag

v1.2.1 - 3 Jun 2018

Improved some error messages

v1.2 - 3 Jun 2018

Added the table type to options! Now you can collect a list of arguments like this:

local getopt = require "lgetopt"
local opts   = {
  options = {
    ["+i"] = {
      help = "Collect inputs",
      type = "table"
    }
  }
}

local argl = getopt (arg, opts)
for k,v in pairs (argl.opt["+i"]) do print (k,v) end

Then call this script like lua example.lua +i file1 +i file2 +i file3 to get this result:

1    file1
2    file2
3    file3

License

As the original code was unlicensed, I don't really see a reason to license it, since most of the changes are minimal.

lgetopt is a command-line argument parser for Lua 5.3 Made by bcnjr5

lgetopt's People

Contributors

daelvn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.