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

@@ -463,4 +463,37 @@ Options:
-h, --help Show this help message and exit.]], cmd2:get_help())
end)
it("allows configuring margins using help_usage_margin and help_description_margin", function()
local parser = Parser "foo"
:help_usage_margin(2)
:help_description_margin(15)
parser:argument "arg1"
:description "Argument number one."
parser:argument "arg2"
:description "Argument number two."
parser:flag "-p"
:description "This is a thing."
parser:option "-f --foo"
:description [[
And this things uses many lines.
Because it has lots of complex behaviour.
That needs documenting.]]
assert.equal([[
Usage: foo [-p] [-f <foo>] [-h] <arg1> <arg2>
Arguments:
arg1 Argument number one.
arg2 Argument number two.
Options:
-p This is a thing.
-f <foo>, And this things uses many lines.
--foo <foo> Because it has lots of complex behaviour.
That needs documenting.
-h, --help Show this help message and exit.]], parser:get_help())
end)
end)