Commit Graph

158 Commits

Author SHA1 Message Date
mpeterv
4fb2991fb2 Add 'concat' action 2015-10-31 19:48:37 +03:00
mpeterv
38b6eb1392 Add :init() property
Allows setting initial stored value. Can be also set using
:default() with a non-string argument.
2015-10-31 19:19:56 +03:00
mpeterv
8343a41dfa Implement string aliases for actions
Added built-in "store_false" action.
2015-10-31 19:09:12 +03:00
mpeterv
4f9841dec6 Implement command actions 2015-10-31 15:50:23 +03:00
mpeterv
decd2040fa Add actions for arguments 2015-10-30 15:18:24 +03:00
mpeterv
babe715548 Change error messages for missing elements
* For arguments: "argument 'foo' is required" -> "missing argument 'foo'"
* For options: "option '--foo' must be used at least 1 time" ->
  "missing option '--foo'"
2015-10-30 15:13:30 +03:00
mpeterv
93522f1856 Add more action tests 2015-10-30 15:04:45 +03:00
mpeterv
247c8a9cce Redesign argument storing
* Use state objects instead of tons of locals in the main
  function.
* Use actions for storing arguments into result table.
  Actions are now called at the end of each invocation,
  with result table, target index, arguments and overwrite flag as
  arguments.
* Remove command actions.
* Improve error messages, refer to options by the last used alias
  instead of the main name.

TODO:

* Improve error messages further ("argument 'foo' is required"
  -> "missing argument 'foo'", etc.).
* Add actions for positional arguments.
* Add actions for commands (should be called with final results
  after parsing is over, in "innermost first" order).
* Allow referring to built-in actions by strings a-la Python
  (e.g. action = "store_false").
* Allow setting initial value to be stored at target index
  for each option (perhaps use default value for that).
* Add more tests, particularly for actions.
2015-10-29 21:00:49 +03:00
mpeterv
98114c6976 Move rockspecs [ci skip] 2015-10-18 20:29:12 +03:00
mpeterv
c1fbb37843 Remove HTML docs from the repo [ci skip] 2015-09-24 19:08:51 +03:00
mpeterv
7134d25ca5 Add coverage gathering 2015-09-24 18:55:10 +03:00
mpeterv
857dca923c Fix travis build 2015-09-24 18:42:56 +03:00
mpeterv
bcfb90880f Update travis config 2015-09-24 17:59:03 +03:00
mpeterv
b3936576be 0.4.1 release 2015-08-08 23:34:50 +03:00
Peter Melnichenko
c3eaee8a3c Merge pull request #3 from jsbackus/jsb_license_to_src
Added license to top of argparse.lua.
2015-08-07 21:14:20 +03:00
Jeff Backus
318c359efd Added license to top of argparse.lua. 2015-08-04 21:57:45 -04:00
mpeterv
75a765623d 0.4.0 release 2015-06-20 18:44:11 +03:00
mpeterv
389d5e0e2e Limit number of properties that can be set as call arguments 2015-06-20 18:27:32 +03:00
mpeterv
d88c84be57 Add typecheck for 'add_help' property 2015-06-20 18:23:29 +03:00
mpeterv
af793c49f3 Generate docs for 0.4.0
It is better to have docs built in the repo so that building
scm version doesn't fail with 'missing doc directory' error.
2015-06-20 18:19:50 +03:00
mpeterv
1210792381 Fix travis build
Create a dummy 'doc' directory to satisfy luarocks.
2015-06-20 17:40:38 +03:00
mpeterv
8dde1f7472 Add tutorial in sphinx/.rst format 2015-06-20 17:34:07 +03:00
Peter Melnichenko
b37cdfe552 Merge pull request #2 from Alloyed/add-handle-options-property
Add handle_options property to Parser
2015-06-18 00:49:31 +03:00
Kyle McLamb
0fedcdeade Add handle_options property to Parser
When `parser:handle_options(true)` (the default), the parser will behave as
before.

When `parser:handle_options(false)`, all options will be passed verbatim
to the argument list, as if the input included double-hyphens.
2015-06-17 04:06:41 -04:00
mpeterv
85809c8ad4 Reorder properties
Move more common properties to the front of property lists,
so that they can be passed as constructor arguments.
E.g.

parser:option "-p" "--port"
   :description "Port number."
   :default "8080"
   :convert(tonumber)

can now be expressed as

parser:option("-p --port", "Port number.", "8080", tonumber)
2015-06-09 22:27:32 +03:00
mpeterv
44fd3b3cb8 Remove 'aliases' property
Allow setting several names using 'name' property instead, e.g.
':name "-f --foo"' instead of ':aliases {"-f", "--foo"}'.

This change breaks documented interface of 0.3.x.
2015-06-09 22:08:16 +03:00
mpeterv
4320f40844 Update travis config
Bump setup scripts, use luacheck.
2015-06-09 21:57:02 +03:00
mpeterv
ff9abac990 Allow using multiple constructor arguments for configuring elements
Disable undocumented ability to specify aliases as arguments
for constructors, e.g. parser:option("-f", "--foo"), and instead
order properties and pass constructor arguments to them.
E.g. parser:argument("foo", "A foo that bars") sets argument
name to foo and description to "A foo that bars".

TODO: remove "aliases" property, instead allow setting several
names in one string by separating them using space.
TODO: reorder properties so that most useful ones could be used
as constructor arguments.
2015-06-09 21:56:36 +03:00
mpeterv
476ad19de8 Avoid printing space at the end of line 2015-03-13 15:40:24 +03:00
mpeterv
01cc387863 Spec cleanups 2015-03-13 15:19:33 +03:00
mpeterv
0da90dc597 Print \n instead of \r\n 2015-03-13 15:12:06 +03:00
mpeterv
9da3d150b1 Add travis testing for Lua 5.3 2015-03-13 14:44:13 +03:00
mpeterv
e14efa01c7 0.3.2 release 2015-01-15 16:34:11 +03:00
mpeterv
dcb17aa8b0 Remove bundled 30log 2015-01-15 16:25:00 +03:00
mpeterv
150fa8e75c Fixed some luacheck warnings 2015-01-15 15:44:41 +03:00
mpeterv
002db5a133 0.3.1 release 2014-11-06 16:31:17 +03:00
mpeterv
5702fd104e Updated README.md 2014-11-06 16:25:26 +03:00
mpeterv
1e940eac8b Bundle 30log
Be compatible with old Luarocks versions, including Luarocks installed
via apt-get and Lua for Windows.
2014-11-06 16:22:49 +03:00
mpeterv
9f3f0adfb1 0.3.0 release 2014-08-25 14:27:07 +04:00
mpeterv
5f7b3f3d0e Updated docs 2014-08-25 14:20:57 +04:00
mpeterv
bd5fd00e6c Custom target should not affect usage and help message generation 2014-08-25 13:51:08 +04:00
mpeterv
b02536d6ba Fixed - being replaced with _ in custom targets
Default argname for options is now default target in brackets
2014-08-25 13:44:26 +04:00
mpeterv
6e02b89b9b Replace - with _ in default target 2014-08-23 11:35:49 +04:00
mpeterv
b8766c8cdf Improved usage message generation
Put options taking variable number of arguments after positional arguments
2014-08-21 15:24:54 +04:00
mpeterv
8c16eca398 Revert autoadding of <> to custom argnames 2014-08-06 13:33:50 +04:00
mpeterv
4b97d03bf5 Added show_default field 2014-08-06 13:02:29 +04:00
Peter Melnichenko
193d448421 Merge pull request #1 from stepelu/fix
Compatibility with strict.lua and other checkers.
2014-08-01 17:52:18 +04:00
mpeterv
59603d5f39 Fixed exploded tests to work with busted 2.0 2014-08-01 17:44:15 +04:00
Stefano Peluchetti
e8b20d9bfc Compatibility with strict.lua and other checkers. 2014-08-01 18:38:58 +09:00
mpeterv
d1386c1d96 Add brackets to argname automatically
Updated aux files
2014-04-24 21:27:22 +04:00