https://github.com/britzl/cmdline
A simple command line argument parser for Lua
https://github.com/britzl/cmdline
lua
Last synced: 6 months ago
JSON representation
A simple command line argument parser for Lua
- Host: GitHub
- URL: https://github.com/britzl/cmdline
- Owner: britzl
- License: mit
- Created: 2014-10-02T09:05:17.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-26T17:19:28.000Z (about 11 years ago)
- Last Synced: 2025-06-19T15:09:51.025Z (10 months ago)
- Topics: lua
- Language: Lua
- Size: 152 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cmdline
=======
A simple command line argument parser for Lua. The command line parser supports both long options (--foobar) and short options (-f).
long options
------------
* Strings of form '--OPTION=VALUE' are parsed to { OPTION = 'VALUE' }.
* Strings of form '--OPTION' are parsed to { OPTION = true }.
* Multiple '--OPTION=VALUE' are merged into { OPTION = { 'VALUE', 'VALUE', ... } }.
short options
-------------
* Strings of form '-O=VALUE' are parsed to { O = 'VALUE' }.
* Strings of form '-O' are parsed to { O = true }.
* Multiple '-O=VALUE' are merged into { O = { 'VALUE', 'VALUE', ... } }.
argument termination
--------------------
The argument '--' terminates all options; any following arguments are treated as non-option arguments, even if they begin with a hyphen.
usage
=====
```
local cmdline = require("cmdline")
local options, arguments = cmdline.parse(...)
```
acknowledgement
===============
Based on the [luvit-cmdline parser](https://github.com/dvv/luvit-cmdline)