mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Add tests for help command
This commit is contained in:
@@ -77,7 +77,7 @@ Did you mean '--from'?
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe("help messages", function()
|
describe("help messages", function()
|
||||||
it("generates correct help message", function()
|
it("generates correct help message using help flag", function()
|
||||||
assert.equal([[
|
assert.equal([[
|
||||||
Usage: ]]..script..[[ [-h] [-v] <input> [<command>] ...
|
Usage: ]]..script..[[ [-h] [-v] <input> [<command>] ...
|
||||||
|
|
||||||
@@ -91,11 +91,31 @@ Options:
|
|||||||
-v, --verbose Sets verbosity level.
|
-v, --verbose Sets verbosity level.
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
help Show help for commands.
|
||||||
install Install a rock.
|
install Install a rock.
|
||||||
]], get_output("--help"))
|
]], get_output("--help"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("generates correct help message for command", function()
|
it("generates correct help message using help command", function()
|
||||||
|
assert.equal([[
|
||||||
|
Usage: ]]..script..[[ [-h] [-v] <input> [<command>] ...
|
||||||
|
|
||||||
|
A testing program.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
input
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this help message and exit.
|
||||||
|
-v, --verbose Sets verbosity level.
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
help Show help for commands.
|
||||||
|
install Install a rock.
|
||||||
|
]], get_output("foo help"))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("generates correct help message for command using help flag", function()
|
||||||
assert.equal([[
|
assert.equal([[
|
||||||
Usage: ]]..script..[[ install [-h] [-f <from>] <rock> [<version>]
|
Usage: ]]..script..[[ install [-h] [-f <from>] <rock> [<version>]
|
||||||
|
|
||||||
@@ -111,6 +131,23 @@ Options:
|
|||||||
--from <from>
|
--from <from>
|
||||||
]], get_output("foo install --help"))
|
]], get_output("foo install --help"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("generates correct help message for command using help command", function()
|
||||||
|
assert.equal([[
|
||||||
|
Usage: ]]..script..[[ install [-h] [-f <from>] <rock> [<version>]
|
||||||
|
|
||||||
|
Install a rock.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
rock Name of the rock.
|
||||||
|
version Version of the rock.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this help message and exit.
|
||||||
|
-f <from>, Fetch the rock from this server.
|
||||||
|
--from <from>
|
||||||
|
]], get_output("foo help install"))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe("data flow", function()
|
describe("data flow", function()
|
||||||
|
@@ -3,6 +3,7 @@ local Parser = require "argparse"
|
|||||||
|
|
||||||
local parser = Parser()
|
local parser = Parser()
|
||||||
:description "A testing program."
|
:description "A testing program."
|
||||||
|
:add_help_command(true)
|
||||||
:require_command(false)
|
:require_command(false)
|
||||||
|
|
||||||
parser:argument "input"
|
parser:argument "input"
|
||||||
|
Reference in New Issue
Block a user