mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 11:02:20 +00:00
Make command required by default
This commit is contained in:
@@ -47,11 +47,11 @@ describe("tests related to commands", function()
|
||||
local parser = Parser "name"
|
||||
parser:command "install"
|
||||
|
||||
assert.has_error(function() parser:parse{} end, "a command is required")
|
||||
|
||||
parser:require_command(false)
|
||||
local args = parser:parse{}
|
||||
assert.same({}, args)
|
||||
|
||||
parser:require_command(true)
|
||||
assert.has_error(function() parser:parse{} end, "a command is required")
|
||||
end)
|
||||
|
||||
it("Detects wrong commands", function()
|
||||
|
@@ -106,7 +106,7 @@ Sets verbosity level.
|
||||
run:option "--where"
|
||||
|
||||
assert.equal(table.concat({
|
||||
"Usage: foo [-q] [-h] [<command>] ...",
|
||||
"Usage: foo [-q] [-h] <command> ...",
|
||||
"",
|
||||
"Options: ",
|
||||
" -q, --quiet",
|
||||
|
@@ -3,6 +3,7 @@ local Parser = require "argparse"
|
||||
|
||||
local parser = Parser "test"
|
||||
:description "A testing program. "
|
||||
:require_command(false)
|
||||
|
||||
parser:argument "input"
|
||||
|
||||
|
@@ -65,7 +65,7 @@ describe("tests related to usage message generation", function()
|
||||
run:option "--where"
|
||||
|
||||
assert.equal(
|
||||
[=[Usage: foo [-q] [<command>] ...]=],
|
||||
[=[Usage: foo [-q] <command> ...]=],
|
||||
parser:prepare():get_usage()
|
||||
)
|
||||
end)
|
||||
|
@@ -48,7 +48,7 @@ local Parser = class {
|
||||
_arguments = {},
|
||||
_options = {},
|
||||
_commands = {},
|
||||
_require_command = false,
|
||||
_require_command = true,
|
||||
_add_help = true,
|
||||
_fields = {
|
||||
"name", "description", "require_command",
|
||||
|
Reference in New Issue
Block a user