126 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
Paul Ouellette
ff9c838e45 Bash completions: add support for nested commands 2019-08-12 10:13:37 -04:00
Paul Ouellette
0b081a1838 Fish completions: fully support nested commands 2019-08-12 10:13:37 -04:00
Paul Ouellette
5a13f0bd06 Fix bash completion error 2019-07-29 20:35:38 -04:00
Paul Ouellette
a7d37b8065 Zsh completions: complete main command options after subcommands 2019-07-26 23:31:09 -04:00
Paul Ouellette
9055452e41 Zsh completions: use #compdef <program>
This means zsh scripts can't be sourced, but they can be automatically
loaded from files which is the standard way of doing it.
2019-07-24 11:06:58 -04:00
Paul Ouellette
5f0cf3721e Completions: validate/escape some missed things 2019-07-23 17:47:07 -04:00
Paul Ouellette
a0c5ddf102 Update completion tests 2019-07-23 17:47:07 -04:00
Paul Ouellette
56e81ad786 Use the base name for completions 2019-07-23 17:47:07 -04:00
Paul Ouellette
e6506bd408 Update completion tests 2019-07-20 09:20:57 -04:00
Paul Ouellette
461f2bd2e5 Completion clean ups 2019-07-18 22:17:09 -04:00
Paul Ouellette
11ae9b8bdf Remove Parser._help_command 2019-07-18 16:26:32 -04:00
Paul Ouellette
0eac53893b Normalize IFS 2019-07-17 22:04:41 -04:00
Paul Ouellette
4f99e3dce0 Add trailing newline to output of complete functions 2019-06-19 14:58:55 -04:00
Paul Ouellette
bcce0fcdcf Small improvements to bash completions 2019-06-18 11:57:03 -04:00
Paul Ouellette
ab7717898c Add tests for bash completions 2019-06-18 11:57:03 -04:00
Paul Ouellette
d5e15583b8 Add tests for fish completions 2019-06-18 11:53:58 -04:00
Paul Ouellette
4509f8f29d Make add_help_command a Parser method 2019-06-17 11:11:26 -04: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
dcd5162710 Add argument choices 2019-05-30 13:55:13 -04:00
Paul Ouellette
16c979220b Remove duplicate test 2019-05-30 13:26:58 -04:00
Paul Ouellette
24398b67ce Add tests for help command 2019-05-25 00:24:49 -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
e33a6ed563 Support -- as an option 2018-04-07 23:21:06 +03:00
Peter Melnichenko
4f72bfeb8e Add hidden property, unlisting elements from usage and help 2018-04-07 22:09:18 +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
caf69bc943 Add a test for concat action + overwrite interaction 2018-03-17 14:09:54 +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
413d3e32f1 Pass command name to command actions 2015-12-09 14:02:23 +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
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