Commit Graph

33 Commits

Author SHA1 Message Date
Paul Ouellette
20c14453fd Add hidden command and option aliases
Also auto-add an alias with dashes in place of underscores if an alias
has an underscore.
2019-12-15 12:29:26 -05:00
daurnimator
e30288c54a Merge remote-tracking branch 'luarocks/refs/pull/3/head' 2019-05-31 22:40:18 +10:00
Paul Ouellette
a8faa0b092 Show choices in help and usage messages 2019-05-30 13:55:13 -04:00
Paul Ouellette
16c979220b Remove duplicate test 2019-05-30 13:26:58 -04:00
Paul Ouellette
55acc1689c Fix tests broken due to change in help flag order 2019-05-24 22:48:27 -04: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
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
dfb012dba0 Add support for grouping elements in help message 2018-04-08 14:03:45 +03:00
Peter Melnichenko
4f72bfeb8e Add hidden property, unlisting elements from usage and help 2018-04-07 22:09:18 +03:00
Peter Melnichenko
3a43d528c6 Fix whitespace warnings 2018-03-16 17:26:31 +03: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
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
0da90dc597 Print \n instead of \r\n 2015-03-13 15:12:06 +03:00
mpeterv
bd5fd00e6c Custom target should not affect usage and help message generation 2014-08-25 13:51:08 +04:00
mpeterv
4b97d03bf5 Added show_default field 2014-08-06 13:02:29 +04:00
mpeterv
59603d5f39 Fixed exploded tests to work with busted 2.0 2014-08-01 17:44:15 +04:00
mpeterv
b4c51e84de Make add_help an actual field 2014-03-02 19:27:37 +04:00
mpeterv
f24cfe9627 Got rid of :prepare() 2014-03-02 02:03:44 +04:00
mpeterv
5c82cb4c2e Added epilog field 2014-02-23 16:44:13 +04:00
mpeterv
7994dded7e Make command required by default 2014-02-23 16:27:23 +04:00
mpeterv
fc65c85a13 Improved command line parsing
The first character after control character is now not required to be a letter
2014-02-23 16:20:55 +04:00
mpeterv
07af666206 Pad long usage messages
Long usage messages are split into lines. A margin is added so that they line up under "Usage: " part of the message.
2014-02-18 13:28:06 +04:00
mpeterv
ccad58ef50 return Parser as the module 2014-02-17 18:41:09 +04:00
mpeterv
3788b9c1a6 Improved help option behaviour
* Help option is only created once per parser, several :prepare() invocations do not create extra options.
* In :add_help(foo), foo is passed to the help option overriding default name, see spec/help_spec.lua @ 24
2014-02-17 16:58:16 +04:00
mpeterv
4dc73cac35 added a test for multiline descriptions 2014-02-17 15:26:04 +04:00
mpeterv
9ae8df55cc added tests related to help, improved help generation 2014-01-26 17:38:22 +04:00