mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-29 03:22:18 +00:00
Avoid printing space at the end of line
This commit is contained in:
@@ -8,7 +8,7 @@ describe("tests related to help message generation", function()
|
|||||||
Usage: foo [-h]
|
Usage: foo [-h]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
-h, --help Show this help message and exit.]], parser:get_help())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("does not create extra help options when :prepare is called several times", function()
|
it("does not create extra help options when :prepare is called several times", function()
|
||||||
@@ -17,7 +17,7 @@ Options:
|
|||||||
Usage: foo [-h]
|
Usage: foo [-h]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
-h, --help Show this help message and exit.]], parser:get_help())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("uses custom help option ", function()
|
it("uses custom help option ", function()
|
||||||
@@ -27,7 +27,7 @@ Options:
|
|||||||
Usage: foo [/?]
|
Usage: foo [/?]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
/? Show this help message and exit. ]], parser:get_help())
|
/? Show this help message and exit.]], parser:get_help())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("uses description and epilog", function()
|
it("uses description and epilog", function()
|
||||||
@@ -68,7 +68,7 @@ Arguments:
|
|||||||
others Optional.
|
others Optional.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this help message and exit. ]], parser:get_help())
|
-h, --help Show this help message and exit.]], parser:get_help())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("creates correct help message for options", function()
|
it("creates correct help message for options", function()
|
||||||
@@ -86,7 +86,7 @@ Options:
|
|||||||
-q, --quiet
|
-q, --quiet
|
||||||
--from <from>
|
--from <from>
|
||||||
--config <config>
|
--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)
|
end)
|
||||||
|
|
||||||
it("adds margin for multiline descriptions", function()
|
it("adds margin for multiline descriptions", function()
|
||||||
@@ -106,7 +106,7 @@ Options:
|
|||||||
-v Sets verbosity level.
|
-v Sets verbosity level.
|
||||||
-v: Report all warnings.
|
-v: Report all warnings.
|
||||||
-vv: Report all debugging information.
|
-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)
|
end)
|
||||||
|
|
||||||
it("shows default values", function()
|
it("shows default values", function()
|
||||||
@@ -123,7 +123,7 @@ Usage: foo [-o <o>] [-p <p>] [-h]
|
|||||||
Options:
|
Options:
|
||||||
-o <o> default: a.out
|
-o <o> default: a.out
|
||||||
-p <p> Port. (default: 8080)
|
-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)
|
end)
|
||||||
|
|
||||||
it("does not show default value when show_default == false", function()
|
it("does not show default value when show_default == false", function()
|
||||||
@@ -142,7 +142,7 @@ Usage: foo [-o <o>] [-p <p>] [-h]
|
|||||||
Options:
|
Options:
|
||||||
-o <o>
|
-o <o>
|
||||||
-p <p> Port.
|
-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)
|
end)
|
||||||
|
|
||||||
it("creates correct help message for commands", function()
|
it("creates correct help message for commands", function()
|
||||||
@@ -174,7 +174,7 @@ Usage: foo run [--where <where>] [-h]
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
--where <where>
|
--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)
|
end)
|
||||||
|
|
||||||
it("uses message provided by user", function()
|
it("uses message provided by user", function()
|
||||||
|
@@ -167,7 +167,7 @@ do
|
|||||||
|
|
||||||
if param then
|
if param then
|
||||||
local help = self:flag()
|
local help = self:flag()
|
||||||
:description "Show this help message and exit. "
|
:description "Show this help message and exit."
|
||||||
:action(function()
|
:action(function()
|
||||||
io.stdout:write(self:get_help() .. "\n")
|
io.stdout:write(self:get_help() .. "\n")
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
@@ -581,7 +581,7 @@ function Parser:get_help()
|
|||||||
table.insert(blocks, self._description)
|
table.insert(blocks, self._description)
|
||||||
end
|
end
|
||||||
|
|
||||||
local labels = {"Arguments: ", "Options: ", "Commands: "}
|
local labels = {"Arguments:", "Options:", "Commands:"}
|
||||||
|
|
||||||
for i, elements in ipairs{self._arguments, self._options, self._commands} do
|
for i, elements in ipairs{self._arguments, self._options, self._commands} do
|
||||||
if #elements > 0 then
|
if #elements > 0 then
|
||||||
|
Reference in New Issue
Block a user