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.
This commit is contained in:
Peter Melnichenko
2018-04-08 16:00:42 +03:00
parent a04899a485
commit 8a3faf3a3e
4 changed files with 95 additions and 14 deletions

View File

@@ -307,4 +307,38 @@ Usage: foo ([--opt1 <opt1>] | [--opt3 <opt3>] | [--opt5 <opt5>])
([<arg4>] | [--opt4 <opt4>])]=], parser:get_usage()
)
end)
it("allows configuring usage margin using usage_margin property", function()
local parser = Parser "foo"
:usage_margin(2)
parser:argument "long_argument_name"
parser:argument "very_long_words"
parser:option "--set-important-property"
parser:option "--include"
:args "*"
assert.equals([=[
Usage: foo [--set-important-property <set_important_property>] [-h]
<long_argument_name> <very_long_words> [--include [<include>] ...]]=], parser:get_usage())
end)
it("allows configuring max usage width using usage_max_width property", function()
local parser = Parser "foo"
:usage_max_width(50)
parser:argument "long_argument_name"
parser:argument "very_long_words"
parser:option "--set-important-property"
parser:option "--include"
:args "*"
assert.equals([=[
Usage: foo
[--set-important-property <set_important_property>]
[-h] <long_argument_name> <very_long_words>
[--include [<include>] ...]]=], parser:get_usage())
end)
end)