Commit Graph

194 Commits

Author SHA1 Message Date
Peter Melnichenko
9019b4fe3a Add doc/ to .gitignore 2018-04-12 14:02:18 +03:00
Peter Melnichenko
b8c12f50e3 Vertically align list item continuation lines when autowrapping 2018-04-10 16:10:56 +03:00
Peter Melnichenko
849622d8e2 Autowrap parser description and epilog, too 2018-04-08 19:10:46 +03:00
Peter Melnichenko
488a8e59a0 Add help_max_width property for help description autowrapping. 2018-04-08 19:03:25 +03:00
Peter Melnichenko
8a3faf3a3e More properties for configuring usage and help messages
* `usage_margin`: sets margin for the second and following lines of
  usage string.
* `usage_max_width`: sets usage max width for autowrapping.
* `help_usage_margin`: sets margin for element usages in help string.
* `help_description`: sets margin for element descrptions in help string.
2018-04-08 16:00:42 +03:00
Peter Melnichenko
a04899a485 Add help_vertical_space Parser property
Sets number of extra newlines to insert between help strings
for different elements within a help group. Inherited by commands.
2018-04-08 15:44:43 +03:00
Peter Melnichenko
46d9182184 Make the module a table with __call metamethod, add .version field
There is little reason to use `_VERSION` instead of `version`.
`_VERSION` global is used by Lua itself, but module tables don't
have to worry about namespace clashes.
2018-04-08 15:25:10 +03:00
Peter Melnichenko
621d5d2709 Update copyright year 2018-04-08 15:20:31 +03:00
Peter Melnichenko
7e1ee83a0b Add a test for help generation with long option argument list 2018-04-08 15:14:46 +03:00
Peter Melnichenko
8baabbbe23 Split labels for multi-alias options into lines in help string 2018-04-08 15:03:56 +03:00
Peter Melnichenko
5c1a6896fc Update changelog 2018-04-08 14:06:17 +03:00
Peter Melnichenko
dfb012dba0 Add support for grouping elements in help message 2018-04-08 14:03:45 +03:00
Peter Melnichenko
e33a6ed563 Support -- as an option 2018-04-07 23:21:06 +03:00
Peter Melnichenko
bf23b082b9 Update changelog 2018-04-07 22:10:38 +03:00
Peter Melnichenko
4f72bfeb8e Add hidden property, unlisting elements from usage and help 2018-04-07 22:09:18 +03:00
Peter Melnichenko
3edbd19b3d Add a changelog 2018-04-07 21:57:30 +03:00
Peter Melnichenko
28604e8411 Rework usage message building and support arguments in mutexes
Ref #11.
2018-03-18 23:28:01 +03:00
Peter Melnichenko
aa740c4270 Allow using separate converters for each argument
When converting an argument in a position, if there is a function
in the same position in provided converer array, use
it as a converter function.

This allows using an array of functions as the value of `convert` property,
with each function applied to corresponding argument of a multi-argument option.

Ref #14.
2018-03-17 14:53:12 +03:00
Peter Melnichenko
7a8236751f Add a test for a automatic invocation of underused option with default value 2018-03-17 14:37:06 +03:00
Peter Melnichenko
8d929db27c Add a test for usage generation for vararg options and mutexes 2018-03-17 14:31:55 +03:00
Peter Melnichenko
d77cd6a5d1 Add tests for property validation 2018-03-17 14:26:45 +03:00
Peter Melnichenko
f0c05d070f Add luacov report files to .gitignore 2018-03-17 14:10:49 +03:00
Peter Melnichenko
caf69bc943 Add a test for concat action + overwrite interaction 2018-03-17 14:09:54 +03:00
Peter Melnichenko
25b04f4c93 Fix codecov call and badge 2018-03-17 13:48:15 +03:00
Peter Melnichenko
8316dc897f Update CI script, switch to codecov for coverage uploads 2018-03-17 13:42:04 +03:00
Peter Melnichenko
b9980b645e Refactor decision making for auto unboxing of single argument elements 2018-03-17 13:37:59 +03:00
Peter Melnichenko
4d06371a07 Fix some line length warnings 2018-03-17 13:34:50 +03:00
Peter Melnichenko
3a43d528c6 Fix whitespace warnings 2018-03-16 17:26:31 +03:00
mpeterv
a40458fdc1 0.5.0 release 2015-12-09 14:19:45 +03:00
mpeterv
bebd56cac8 Document command action second argument 2015-12-09 14:03:35 +03:00
mpeterv
413d3e32f1 Pass command name to command actions 2015-12-09 14:02:23 +03:00
mpeterv
9e5524e8ea Document new actions 2015-12-09 13:59:41 +03:00
mpeterv
1fa69cbf30 Document command_target 2015-12-09 13:05:48 +03:00
mpeterv
247ed9e874 New Parser/Command property 'command_target'
Allows saving name of used command in a field of result target.
Helpful when command callbacks are stored in a table with names as keys
or when they are in submodules of some namespace.

Example:

    local parser = argparse():command_target("command")
    -- Add commands...
    local args = parser:parse()
    require("namespace." .. args.command).run(args)
2015-11-23 15:54:31 +03:00
mpeterv
79952deb42 Respect empty initial value in 'append' and 'concat' actions 2015-10-31 20:02:56 +03:00
mpeterv
6dc13c3d26 Fix option combining
Interpret '-f123' as '-f 123' if '-f' option can take an argument,
even when it can be used without one as well.
2015-10-31 20:01:16 +03:00
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