mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 11:02:20 +00:00
Fix whitespace warnings
This commit is contained in:
@@ -183,7 +183,7 @@ describe("actions", function()
|
|||||||
|
|
||||||
it("for commands are called in reverse order", function()
|
it("for commands are called in reverse order", function()
|
||||||
local args = {}
|
local args = {}
|
||||||
|
|
||||||
local parser = Parser():action(function(passed_args)
|
local parser = Parser():action(function(passed_args)
|
||||||
args[1] = passed_args
|
args[1] = passed_args
|
||||||
args.last = 1
|
args.last = 1
|
||||||
|
@@ -51,7 +51,7 @@ An epilog.]], parser:get_help())
|
|||||||
:args "2"
|
:args "2"
|
||||||
parser:argument "maybe-fourth"
|
parser:argument "maybe-fourth"
|
||||||
:args "?"
|
:args "?"
|
||||||
parser:argument("others", "Optional. ")
|
parser:argument("others", "Optional.")
|
||||||
:args "*"
|
:args "*"
|
||||||
|
|
||||||
assert.equal([[
|
assert.equal([[
|
||||||
@@ -62,7 +62,7 @@ Arguments:
|
|||||||
first
|
first
|
||||||
second-and-third
|
second-and-third
|
||||||
maybe-fourth
|
maybe-fourth
|
||||||
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())
|
||||||
@@ -92,17 +92,17 @@ Options:
|
|||||||
:count "0-2"
|
:count "0-2"
|
||||||
:target "verbosity"
|
:target "verbosity"
|
||||||
:description [[
|
:description [[
|
||||||
Sets verbosity level.
|
Sets verbosity level.
|
||||||
-v: Report all warnings.
|
-v: Report all warnings.
|
||||||
-vv: Report all debugging information. ]]
|
-vv: Report all debugging information.]]
|
||||||
|
|
||||||
assert.equal([[
|
assert.equal([[
|
||||||
Usage: foo [-v] [-h]
|
Usage: foo [-v] [-h]
|
||||||
|
|
||||||
Options:
|
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)
|
||||||
|
|
||||||
@@ -131,14 +131,14 @@ Options:
|
|||||||
parser:option "-p"
|
parser:option "-p"
|
||||||
:default "8080"
|
:default "8080"
|
||||||
:show_default(false)
|
:show_default(false)
|
||||||
:description "Port. "
|
:description "Port."
|
||||||
|
|
||||||
assert.equal([[
|
assert.equal([[
|
||||||
Usage: foo [-o <o>] [-p <p>] [-h]
|
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)
|
||||||
|
|
||||||
|
@@ -81,17 +81,17 @@ Did you mean '--from'?
|
|||||||
assert.equal([[
|
assert.equal([[
|
||||||
Usage: ]]..script..[[ [-v] [-h] <input> [<command>] ...
|
Usage: ]]..script..[[ [-v] [-h] <input> [<command>] ...
|
||||||
|
|
||||||
A testing program.
|
A testing program.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
input
|
input
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-v, --verbose Sets verbosity level.
|
-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.
|
install Install a rock.
|
||||||
]], get_output("--help"))
|
]], get_output("--help"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -99,15 +99,15 @@ Commands:
|
|||||||
assert.equal([[
|
assert.equal([[
|
||||||
Usage: ]]..script..[[ install [-f <from>] [-h] <rock> [<version>]
|
Usage: ]]..script..[[ install [-f <from>] [-h] <rock> [<version>]
|
||||||
|
|
||||||
Install a rock.
|
Install a rock.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
rock Name of the rock.
|
rock Name of the rock.
|
||||||
version Version of the rock.
|
version Version of the rock.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-f <from>, --from <from>
|
-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.
|
||||||
]], get_output("foo install --help"))
|
]], get_output("foo install --help"))
|
||||||
end)
|
end)
|
||||||
|
@@ -2,28 +2,28 @@
|
|||||||
local Parser = require "argparse"
|
local Parser = require "argparse"
|
||||||
|
|
||||||
local parser = Parser()
|
local parser = Parser()
|
||||||
:description "A testing program. "
|
:description "A testing program."
|
||||||
:require_command(false)
|
:require_command(false)
|
||||||
|
|
||||||
parser:argument "input"
|
parser:argument "input"
|
||||||
|
|
||||||
parser:flag "-v" "--verbose"
|
parser:flag "-v" "--verbose"
|
||||||
:description "Sets verbosity level. "
|
:description "Sets verbosity level."
|
||||||
:target "verbosity"
|
:target "verbosity"
|
||||||
:count "0-2"
|
:count "0-2"
|
||||||
|
|
||||||
local install = parser:command "install"
|
local install = parser:command "install"
|
||||||
:description "Install a rock. "
|
:description "Install a rock."
|
||||||
|
|
||||||
install:argument "rock"
|
install:argument "rock"
|
||||||
:description "Name of the rock. "
|
:description "Name of the rock."
|
||||||
|
|
||||||
install:argument "version"
|
install:argument "version"
|
||||||
:description "Version of the rock. "
|
:description "Version of the rock."
|
||||||
:args "?"
|
:args "?"
|
||||||
|
|
||||||
install:option "-f" "--from"
|
install:option "-f" "--from"
|
||||||
:description "Fetch the rock from this server. "
|
:description "Fetch the rock from this server."
|
||||||
:target "server"
|
:target "server"
|
||||||
|
|
||||||
parser:get_usage()
|
parser:get_usage()
|
||||||
|
@@ -48,7 +48,7 @@ local function class(prototype, properties, parent)
|
|||||||
if properties then
|
if properties then
|
||||||
local names = {}
|
local names = {}
|
||||||
|
|
||||||
-- Create setter methods and fill set of property names.
|
-- Create setter methods and fill set of property names.
|
||||||
for _, property in ipairs(properties) do
|
for _, property in ipairs(properties) do
|
||||||
local name, callback = property[1], property[2]
|
local name, callback = property[1], property[2]
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ function Argument:_get_action()
|
|||||||
return action, init
|
return action, init
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns placeholder for `narg`-th argument.
|
-- Returns placeholder for `narg`-th argument.
|
||||||
function Argument:_get_argname(narg)
|
function Argument:_get_argname(narg)
|
||||||
local argname = self._argname or self:_get_default_argname()
|
local argname = self._argname or self:_get_default_argname()
|
||||||
|
|
||||||
@@ -441,7 +441,7 @@ function Option:_get_default_argname()
|
|||||||
return "<" .. 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.
|
||||||
function Argument:_get_label()
|
function Argument:_get_label()
|
||||||
return self._name
|
return self._name
|
||||||
end
|
end
|
||||||
@@ -687,7 +687,7 @@ function Parser:get_help()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local blocks = {self:get_usage()}
|
local blocks = {self:get_usage()}
|
||||||
|
|
||||||
if self._description then
|
if self._description then
|
||||||
table.insert(blocks, self._description)
|
table.insert(blocks, self._description)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user