mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-29 03:22:18 +00:00
Custom target should not affect usage and help message generation
This commit is contained in:
@@ -85,11 +85,11 @@ describe("tests related to help message generation", function()
|
|||||||
parser:option "--config"
|
parser:option "--config"
|
||||||
|
|
||||||
assert.equal(table.concat({
|
assert.equal(table.concat({
|
||||||
"Usage: foo [-q] --from <server> [--config <config>] [-h]",
|
"Usage: foo [-q] --from <from> [--config <config>] [-h]",
|
||||||
"",
|
"",
|
||||||
"Options: ",
|
"Options: ",
|
||||||
" -q, --quiet",
|
" -q, --quiet",
|
||||||
" --from <server>",
|
" --from <from>",
|
||||||
" --config <config>",
|
" --config <config>",
|
||||||
" -h, --help Show this help message and exit. "
|
" -h, --help Show this help message and exit. "
|
||||||
}, "\r\n"), parser:get_help())
|
}, "\r\n"), parser:get_help())
|
||||||
|
@@ -60,7 +60,7 @@ describe("tests related to CLI behaviour #unsafe", function()
|
|||||||
it("generates correct error message without arguments in command", function()
|
it("generates correct error message without arguments in command", function()
|
||||||
local handler = io.popen("./spec/script foo install 2>&1", "r")
|
local handler = io.popen("./spec/script foo install 2>&1", "r")
|
||||||
assert.equal(table.concat({
|
assert.equal(table.concat({
|
||||||
"Usage: ./spec/script install [-f <server>] [-h] <rock> [<version>]",
|
"Usage: ./spec/script install [-f <from>] [-h] <rock> [<version>]",
|
||||||
"",
|
"",
|
||||||
"Error: too few arguments",
|
"Error: too few arguments",
|
||||||
""
|
""
|
||||||
@@ -71,7 +71,7 @@ describe("tests related to CLI behaviour #unsafe", function()
|
|||||||
it("generates correct error message and tip in command", function()
|
it("generates correct error message and tip in command", function()
|
||||||
local handler = io.popen("./spec/script foo install bar --form=there 2>&1", "r")
|
local handler = io.popen("./spec/script foo install bar --form=there 2>&1", "r")
|
||||||
assert.equal(table.concat({
|
assert.equal(table.concat({
|
||||||
"Usage: ./spec/script install [-f <server>] [-h] <rock> [<version>]",
|
"Usage: ./spec/script install [-f <from>] [-h] <rock> [<version>]",
|
||||||
"",
|
"",
|
||||||
"Error: unknown option '--form'",
|
"Error: unknown option '--form'",
|
||||||
"Did you mean '--from'?",
|
"Did you mean '--from'?",
|
||||||
@@ -106,7 +106,7 @@ describe("tests related to CLI behaviour #unsafe", function()
|
|||||||
it("generates correct help message for command", function()
|
it("generates correct help message for command", function()
|
||||||
local handler = io.popen("./spec/script foo install --help 2>&1", "r")
|
local handler = io.popen("./spec/script foo install --help 2>&1", "r")
|
||||||
assert.equal(table.concat({
|
assert.equal(table.concat({
|
||||||
"Usage: ./spec/script install [-f <server>] [-h] <rock> [<version>]",
|
"Usage: ./spec/script install [-f <from>] [-h] <rock> [<version>]",
|
||||||
"",
|
"",
|
||||||
"Install a rock. ",
|
"Install a rock. ",
|
||||||
"",
|
"",
|
||||||
@@ -115,7 +115,7 @@ describe("tests related to CLI behaviour #unsafe", function()
|
|||||||
" version Version of the rock. ",
|
" version Version of the rock. ",
|
||||||
"",
|
"",
|
||||||
"Options: ",
|
"Options: ",
|
||||||
" -f <server>, --from <server>",
|
" -f <from>, --from <from>",
|
||||||
" Fetch the rock from this server. ",
|
" Fetch the rock from this server. ",
|
||||||
" -h, --help Show this help message and exit. ",
|
" -h, --help Show this help message and exit. ",
|
||||||
"",
|
"",
|
||||||
|
@@ -36,7 +36,7 @@ describe("tests related to usage message generation", function()
|
|||||||
parser:option "--config"
|
parser:option "--config"
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
[=[Usage: foo [-q] --from <server> [--config <config>]]=],
|
[=[Usage: foo [-q] --from <from> [--config <config>]]=],
|
||||||
parser:get_usage()
|
parser:get_usage()
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
@@ -306,7 +306,7 @@ function Argument:_get_default_argname()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Option:_get_default_argname()
|
function Option:_get_default_argname()
|
||||||
return "<" .. (self._target or self:_get_default_target()) .. ">"
|
return "<" .. self:_get_default_target() .. ">"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns label to be shown in the help message.
|
-- Returns label to be shown in the help message.
|
||||||
|
Reference in New Issue
Block a user