mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Avoid printing space at the end of line
This commit is contained in:
@@ -7,8 +7,8 @@ describe("tests related to help message generation", function()
|
||||
assert.equal([[
|
||||
Usage: foo [-h]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
||||
Options:
|
||||
-h, --help Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("does not create extra help options when :prepare is called several times", function()
|
||||
@@ -16,8 +16,8 @@ Options:
|
||||
assert.equal([[
|
||||
Usage: foo [-h]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
||||
Options:
|
||||
-h, --help Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("uses custom help option ", function()
|
||||
@@ -26,8 +26,8 @@ Options:
|
||||
assert.equal([[
|
||||
Usage: foo [/?]
|
||||
|
||||
Options:
|
||||
/? Show this help message and exit. ]], parser:get_help())
|
||||
Options:
|
||||
/? Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("uses description and epilog", function()
|
||||
@@ -40,8 +40,8 @@ Usage: foo [-h]
|
||||
|
||||
A description.
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message and exit.
|
||||
Options:
|
||||
-h, --help Show this help message and exit.
|
||||
|
||||
An epilog. ]], parser:get_help())
|
||||
end)
|
||||
@@ -61,14 +61,14 @@ An epilog. ]], parser:get_help())
|
||||
Usage: foo [-h] <first> <second-and-third> <second-and-third>
|
||||
[<maybe-fourth>] [<others>] ...
|
||||
|
||||
Arguments:
|
||||
Arguments:
|
||||
first
|
||||
second-and-third
|
||||
maybe-fourth
|
||||
others Optional.
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
||||
Options:
|
||||
-h, --help Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("creates correct help message for options", function()
|
||||
@@ -82,11 +82,11 @@ Options:
|
||||
assert.equal([[
|
||||
Usage: foo [-q] --from <from> [--config <config>] [-h]
|
||||
|
||||
Options:
|
||||
Options:
|
||||
-q, --quiet
|
||||
--from <from>
|
||||
--config <config>
|
||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
||||
-h, --help Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("adds margin for multiline descriptions", function()
|
||||
@@ -102,11 +102,11 @@ Sets verbosity level.
|
||||
assert.equal([[
|
||||
Usage: foo [-v] [-h]
|
||||
|
||||
Options:
|
||||
Options:
|
||||
-v Sets verbosity level.
|
||||
-v: Report all warnings.
|
||||
-vv: Report all debugging information.
|
||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
||||
-h, --help Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("shows default values", function()
|
||||
@@ -120,10 +120,10 @@ Options:
|
||||
assert.equal([[
|
||||
Usage: foo [-o <o>] [-p <p>] [-h]
|
||||
|
||||
Options:
|
||||
Options:
|
||||
-o <o> default: a.out
|
||||
-p <p> Port. (default: 8080)
|
||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
||||
-h, --help Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("does not show default value when show_default == false", function()
|
||||
@@ -139,10 +139,10 @@ Options:
|
||||
assert.equal([[
|
||||
Usage: foo [-o <o>] [-p <p>] [-h]
|
||||
|
||||
Options:
|
||||
Options:
|
||||
-o <o>
|
||||
-p <p> Port.
|
||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
||||
-h, --help Show this help message and exit.]], parser:get_help())
|
||||
end)
|
||||
|
||||
it("creates correct help message for commands", function()
|
||||
@@ -155,11 +155,11 @@ Options:
|
||||
assert.equal([[
|
||||
Usage: foo [-q] [-h] <command> ...
|
||||
|
||||
Options:
|
||||
Options:
|
||||
-q, --quiet
|
||||
-h, --help Show this help message and exit.
|
||||
-h, --help Show this help message and exit.
|
||||
|
||||
Commands:
|
||||
Commands:
|
||||
run Run! ]], parser:get_help())
|
||||
end)
|
||||
|
||||
@@ -172,9 +172,9 @@ Commands:
|
||||
assert.equal([[
|
||||
Usage: foo run [--where <where>] [-h]
|
||||
|
||||
Options:
|
||||
Options:
|
||||
--where <where>
|
||||
-h, --help Show this help message and exit. ]], run:get_help())
|
||||
-h, --help Show this help message and exit.]], run:get_help())
|
||||
end)
|
||||
|
||||
it("uses message provided by user", function()
|
||||
|
@@ -74,14 +74,14 @@ Usage: ./spec/script [-v] [-h] <input> [<command>] ...
|
||||
|
||||
A testing program.
|
||||
|
||||
Arguments:
|
||||
Arguments:
|
||||
input
|
||||
|
||||
Options:
|
||||
Options:
|
||||
-v, --verbose Sets verbosity level.
|
||||
-h, --help Show this help message and exit.
|
||||
-h, --help Show this help message and exit.
|
||||
|
||||
Commands:
|
||||
Commands:
|
||||
install Install a rock.
|
||||
]], get_output("--help"))
|
||||
end)
|
||||
@@ -92,14 +92,14 @@ Usage: ./spec/script install [-f <from>] [-h] <rock> [<version>]
|
||||
|
||||
Install a rock.
|
||||
|
||||
Arguments:
|
||||
Arguments:
|
||||
rock Name of the rock.
|
||||
version Version of the rock.
|
||||
|
||||
Options:
|
||||
Options:
|
||||
-f <from>, --from <from>
|
||||
Fetch the rock from this server.
|
||||
-h, --help Show this help message and exit.
|
||||
-h, --help Show this help message and exit.
|
||||
]], get_output("foo install --help"))
|
||||
end)
|
||||
end)
|
||||
|
@@ -167,7 +167,7 @@ do
|
||||
|
||||
if param then
|
||||
local help = self:flag()
|
||||
:description "Show this help message and exit. "
|
||||
:description "Show this help message and exit."
|
||||
:action(function()
|
||||
io.stdout:write(self:get_help() .. "\n")
|
||||
os.exit(0)
|
||||
@@ -581,7 +581,7 @@ function Parser:get_help()
|
||||
table.insert(blocks, self._description)
|
||||
end
|
||||
|
||||
local labels = {"Arguments: ", "Options: ", "Commands: "}
|
||||
local labels = {"Arguments:", "Options:", "Commands:"}
|
||||
|
||||
for i, elements in ipairs{self._arguments, self._options, self._commands} do
|
||||
if #elements > 0 then
|
||||
|
Reference in New Issue
Block a user