XUtils

cliargs

A simple command-line argument parsing module.


API

See http://lua-cliargs.netlify.com/ for the API docs.

Validations

Some sanity guards

In the following cases, cliargs will report an error to you and terminate the running script:

  1. flag options can not accept a value. For example: cli:add_flag('-v VERSION') will return an error
  2. duplicate keys are not allowed: defining two options with the key --input will be rejected

Tests

Running test specs is done using busted. You can install it using LuaRocks, and then just call it with the spec folder:

luarocks install busted
cd /path/to/lua_cliargs/
busted spec

Contributions

If you come across a bug and you’d like to patch it, please fork the repository, commit your patch, and request a pull.

Thanks to

Many thanks to everyone who reported bugs, provided fixes, and added entirely new features:

  1. Thijs Schreijer
  2. Jack Lawson
  3. Robert Andrew Ditthardt
  4. Oscar Lim

If I missed you, don’t hesitate to update this file or just email me.

Changelog

3.0-2

  • optimized an internal routine responsible for word-wrapping. Thanks to @Tieske, refs GH-47

Changes from 2.5.1 to 2.5.2

  • No longer tracking the (legacy) tarballs in git or the luarocks package. Instead, we use the GitHub release tarballs for each version.

Changes in 2.4.0 from 2.3-4

  1. All arguments now accept a callback that will be invoked when parsing of those arguments was successful
  2. (POSSIBLY BREAKING) Default value for flags is now nil instead of false. This will only affect existing behavior if you were explicitly testing unset flags to equal false (i.e. if flag == false then) as opposed to if flag then (or if not flag then).
  3. Minor bugfixes

Changes in 2.2-0 from 2.1-2

  1. the = that separates keys from values in the --expanded-key notation is no longer mandatory; using either a space or a = will map the value to the key (e.g., --compress lzma is equal to --compress=lzma)

Articles

  • coming soon...