return Parser as the module

This commit is contained in:
mpeterv
2014-02-17 18:41:09 +04:00
parent 3788b9c1a6
commit ccad58ef50
12 changed files with 109 additions and 117 deletions

View File

@@ -1,11 +1,11 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to actions", function()
it("calls actions for options", function()
local action1 = spy.new(function(x) end)
local action2 = spy.new(function(x) end)
local parser = argparse.parser()
local parser = Parser()
parser:option "-f" "--from" {
action = action1
}
@@ -29,7 +29,7 @@ describe("tests related to actions", function()
local action2 = spy.new(function(x) end)
local action3 = spy.new(function(x) end)
local parser = argparse.parser()
local parser = Parser()
parser:flag "-v" "--verbose" {
action = action1,
count = "0-3"
@@ -52,7 +52,7 @@ describe("tests related to actions", function()
local action1 = spy.new(function(x) end)
local action2 = spy.new(function(x) end)
local parser = argparse.parser()
local parser = Parser()
parser:argument "input" {
action = action1
}
@@ -73,7 +73,7 @@ describe("tests related to actions", function()
local action1 = spy.new(function(x) end)
local action2 = spy.new(function(x) end)
local parser = argparse.parser "name" {
local parser = Parser "name" {
action = action1
}
parser:flag "-v" "--verbose" {

View File

@@ -1,22 +1,22 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to positional arguments", function()
describe("passing correct arguments", function()
it("handles empty parser correctly", function()
local parser = argparse.parser()
local parser = Parser()
local args = parser:parse({})
assert.same({}, args)
end)
it("handles one argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo"
local args = parser:parse({"bar"})
assert.same({foo = "bar"}, args)
end)
it("handles optional argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo"
:args "?"
local args = parser:parse({"bar"})
@@ -24,7 +24,7 @@ describe("tests related to positional arguments", function()
end)
it("handles several arguments correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo1"
parser:argument "foo2"
local args = parser:parse({"bar", "baz"})
@@ -32,7 +32,7 @@ describe("tests related to positional arguments", function()
end)
it("handles multi-argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo", {
args = "*"
})
@@ -41,7 +41,7 @@ describe("tests related to positional arguments", function()
end)
it("handles restrained multi-argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo", {
args = "2-4"
})
@@ -50,7 +50,7 @@ describe("tests related to positional arguments", function()
end)
it("handles several multi-arguments correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo1", {
args = "1-2"
})
@@ -64,14 +64,14 @@ describe("tests related to positional arguments", function()
end)
it("handles hyphen correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo"
local args = parser:parse({"-"})
assert.same({foo = "-"}, args)
end)
it("handles double hyphen correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo"
local args = parser:parse({"--", "-q"})
assert.same({foo = "-q"}, args)
@@ -80,27 +80,27 @@ describe("tests related to positional arguments", function()
describe("passing incorrect arguments", function()
it("handles extra arguments with empty parser correctly", function()
local parser = argparse.parser()
local parser = Parser()
assert.has_error(function() parser:parse{"foo"} end, "too many arguments")
end)
it("handles extra arguments with one argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo"
assert.has_error(function() parser:parse{"bar", "baz"} end, "too many arguments")
end)
it("handles too few arguments with one argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo"
assert.has_error(function() parser:parse{} end, "too few arguments")
end)
it("handles extra arguments with several arguments correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo1"
parser:argument "foo2"
@@ -108,7 +108,7 @@ describe("tests related to positional arguments", function()
end)
it("handles too few arguments with several arguments correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo1"
parser:argument "foo2"
@@ -116,7 +116,7 @@ describe("tests related to positional arguments", function()
end)
it("handles too few arguments with multi-argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo" {
args = "+"
}
@@ -124,7 +124,7 @@ describe("tests related to positional arguments", function()
end)
it("handles too many arguments with multi-argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "foo" {
args = "2-4"
}
@@ -132,7 +132,7 @@ describe("tests related to positional arguments", function()
end)
it("handles too few arguments with multi-argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo", {
args = "2-4"
})
@@ -140,7 +140,7 @@ describe("tests related to positional arguments", function()
end)
it("handles too many arguments with several multi-arguments correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo1", {
args = "1-2"
})
@@ -151,7 +151,7 @@ describe("tests related to positional arguments", function()
end)
it("handles too few arguments with several multi-arguments correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo1", {
args = "1-2"
})

View File

@@ -1,8 +1,8 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to commands", function()
it("handles commands after arguments", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:argument "file"
parser:command "create"
parser:command "remove"
@@ -12,7 +12,7 @@ describe("tests related to commands", function()
end)
it("switches context properly", function()
local parser = argparse.parser "name"
local parser = Parser "name"
:add_help(false)
local install = parser:command "install"
install:flag "-q" "--quiet"
@@ -23,7 +23,7 @@ describe("tests related to commands", function()
end)
it("allows to continue passing old options", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:flag "-v" "--verbose" {
count = "*"
}
@@ -34,7 +34,7 @@ describe("tests related to commands", function()
end)
it("handles nested commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
local foo = parser:command "foo"
local bar = foo:command "bar"
local baz = foo:command "baz"
@@ -44,7 +44,7 @@ describe("tests related to commands", function()
end)
it("handles no commands depending on parser.require_command", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:command "install"
local args = parser:parse{}
@@ -55,7 +55,7 @@ describe("tests related to commands", function()
end)
it("Detects wrong commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
local install = parser:command "install"
assert.has_error(function() parser:parse{"run"} end, "unknown command 'run'")

View File

@@ -1,8 +1,8 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to converters", function()
it("converts arguments", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "numbers" {
convert = tonumber,
args = "+"
@@ -13,7 +13,7 @@ describe("tests related to converters", function()
end)
it("raises an error when it can't convert", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "numbers" {
convert = tonumber,
args = "+"
@@ -23,7 +23,7 @@ describe("tests related to converters", function()
end)
it("second return value is used as error message", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument "numbers" {
convert = function(x) return tonumber(x), x .. " is not a number" end
}

View File

@@ -1,9 +1,9 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to default values", function()
describe("default values for arguments", function()
it("handles default argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo", {
default = "bar"
})
@@ -12,7 +12,7 @@ describe("tests related to default values", function()
end)
it("handles default multi-argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo", {
args = 3,
default = "bar"
@@ -22,7 +22,7 @@ describe("tests related to default values", function()
end)
it("does not use default values if not needed", function()
local parser = argparse.parser()
local parser = Parser()
parser:argument("foo", {
args = "1-2",
default = "bar"
@@ -34,7 +34,7 @@ describe("tests related to default values", function()
describe("default values for options", function()
it("handles option with default value correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-f", "--foo", {
default = "bar"
})
@@ -43,7 +43,7 @@ describe("tests related to default values", function()
end)
it("doesn't use default if option is not invoked", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-f", "--foo", {
default = "bar"
})
@@ -52,7 +52,7 @@ describe("tests related to default values", function()
end)
it("handles default multi-argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-f", "--foo", {
args = 3,
default = "bar"
@@ -62,7 +62,7 @@ describe("tests related to default values", function()
end)
it("does not use default values if not needed", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-f", "--foo", {
args = "1-2",
default = "bar"
@@ -72,7 +72,7 @@ describe("tests related to default values", function()
end)
it("handles multi-count options with default value correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-f", "--foo", {
count = "*",
default = "bar"

View File

@@ -1,8 +1,8 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to help message generation", function()
it("creates correct help message for empty parser", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
assert.equal(table.concat({
"Usage: foo [-h]",
"",
@@ -12,7 +12,7 @@ describe("tests related to help message generation", function()
end)
it("does not create extra help options when :prepare is called several times", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
assert.equal(table.concat({
"Usage: foo [-h]",
"",
@@ -22,7 +22,7 @@ describe("tests related to help message generation", function()
end)
it("uses custom help option", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help {aliases = {"\\?"}}
assert.equal(table.concat({
"Usage: foo [\\?]",
@@ -33,7 +33,7 @@ describe("tests related to help message generation", function()
end)
it("creates correct help message for arguments", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
parser:argument "first"
parser:argument "second-and-third"
:args "2"
@@ -58,7 +58,7 @@ describe("tests related to help message generation", function()
end)
it("creates correct help message for options", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
parser:flag "-q" "--quiet"
parser:option "--from"
:count "1"
@@ -77,7 +77,7 @@ describe("tests related to help message generation", function()
end)
it("adds margin for multiline descriptions", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
parser:flag "-v"
:count "0-2"
:target "verbosity"
@@ -98,7 +98,7 @@ Sets verbosity level.
end)
it("creates correct help message for commands", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
parser:flag "-q" "--quiet"
local run = parser:command "run"
:description "Run! "
@@ -117,7 +117,7 @@ Sets verbosity level.
end)
it("creates correct help message for subcommands", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
parser:flag "-q" "--quiet"
local run = parser:command "run"
run:option "--where"
@@ -134,7 +134,7 @@ Sets verbosity level.
end)
it("uses message provided by user", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:help "I don't like your format of help messages"
parser:flag "-q" "--quiet"

View File

@@ -1,4 +1,4 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to CLI behaviour #unsafe", function()
describe("error messages", function()

View File

@@ -1,30 +1,30 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to options", function()
describe("passing correct options", function()
it("handles no options passed correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server")
local args = parser:parse({})
assert.same({}, args)
end)
it("handles one option correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server")
local args = parser:parse({"--server", "foo"})
assert.same({server = "foo"}, args)
end)
it("handles GNU-style long options", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server")
local args = parser:parse({"--server=foo"})
assert.same({server = "foo"}, args)
end)
it("handles GNU-style long options even when it could take more arguments", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server", {
args = "*"
})
@@ -33,7 +33,7 @@ describe("tests related to options", function()
end)
it("handles GNU-style long options for multi-argument options", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server", {
args = "1-2"
})
@@ -42,14 +42,14 @@ describe("tests related to options", function()
end)
it("handles short option correclty", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server")
local args = parser:parse({"-s", "foo"})
assert.same({server = "foo"}, args)
end)
it("handles flag correclty", function()
local parser = argparse.parser()
local parser = Parser()
parser:flag("-q", "--quiet")
local args = parser:parse({"--quiet"})
assert.same({quiet = true}, args)
@@ -58,7 +58,7 @@ describe("tests related to options", function()
end)
it("handles combined flags correclty", function()
local parser = argparse.parser()
local parser = Parser()
parser:flag("-q", "--quiet")
parser:flag("-f", "--fast")
local args = parser:parse({"-qf"})
@@ -66,14 +66,14 @@ describe("tests related to options", function()
end)
it("handles short options without space between option and argument", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server")
local args = parser:parse({"-sfoo"})
assert.same({server = "foo"}, args)
end)
it("handles flags combined with short option correclty", function()
local parser = argparse.parser()
local parser = Parser()
parser:flag("-q", "--quiet")
parser:option("-s", "--server")
local args = parser:parse({"-qsfoo"})
@@ -82,7 +82,7 @@ describe("tests related to options", function()
describe("Special chars set", function()
it("handles windows-style options", function()
local parser = argparse.parser()
local parser = Parser()
:add_help(false)
parser:option "\\I"
:count "*"
@@ -92,7 +92,7 @@ describe("tests related to options", function()
end)
it("corrects charset in commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
:add_help(false)
parser:flag "-v" "--verbose"
:count "*"
@@ -106,7 +106,7 @@ describe("tests related to options", function()
describe("Options with optional argument", function()
it("handles emptiness correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-p", "--password", {
args = "?"
})
@@ -115,7 +115,7 @@ describe("tests related to options", function()
end)
it("handles option without argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-p", "--password", {
args = "?"
})
@@ -124,7 +124,7 @@ describe("tests related to options", function()
end)
it("handles option with argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-p", "--password", {
args = "?"
})
@@ -134,7 +134,7 @@ describe("tests related to options", function()
end)
it("handles multi-argument options correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("--pair", {
args = 2
})
@@ -144,7 +144,7 @@ describe("tests related to options", function()
describe("Multi-count options", function()
it("handles multi-count option correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-e", "--exclude", {
count = "*"
})
@@ -153,7 +153,7 @@ describe("tests related to options", function()
end)
it("handles not used multi-count option correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-e", "--exclude", {
count = "*"
})
@@ -162,7 +162,7 @@ describe("tests related to options", function()
end)
it("handles multi-count multi-argument option correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-e", "--exclude", {
count = "*",
args = 2
@@ -172,7 +172,7 @@ describe("tests related to options", function()
end)
it("handles multi-count flag correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:flag("-q", "--quiet", {
count = "*"
})
@@ -181,7 +181,7 @@ describe("tests related to options", function()
end)
it("overwrites old invocations", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-u", "--user", {
count = "0-2"
})
@@ -190,7 +190,7 @@ describe("tests related to options", function()
end)
it("handles not used multi-count flag correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:flag("-q", "--quiet", {
count = "*"
})
@@ -202,13 +202,13 @@ describe("tests related to options", function()
describe("passing incorrect options", function()
it("handles lack of required argument correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server")
assert.has_error(function() parser:parse{"--server"} end, "too few arguments")
end)
it("handles unknown options correctly", function()
local parser = argparse.parser()
local parser = Parser()
:add_help(false)
parser:option "--option"
assert.has_error(function() parser:parse{"--server"} end, "unknown option '--server'")
@@ -218,19 +218,19 @@ describe("tests related to options", function()
end)
it("handles too many arguments correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-s", "--server")
assert.has_error(function() parser:parse{"-sfoo", "bar"} end, "too many arguments")
end)
it("doesn't accept GNU-like long options when it doesn't need arguments", function()
local parser = argparse.parser()
local parser = Parser()
parser:flag("-q", "--quiet")
assert.has_error(function() parser:parse{"--quiet=very_quiet"} end, "option '--quiet' does not take arguments")
end)
it("handles too many invocations correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:flag("-q", "--quiet", {
count = 1,
overwrite = false
@@ -239,7 +239,7 @@ describe("tests related to options", function()
end)
it("handles too few invocations correctly", function()
local parser = argparse.parser()
local parser = Parser()
parser:option("-f", "--foo", {
count = "3-4"
})

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env lua
local argparse = require "argparse"
local Parser = require "argparse"
local parser = argparse.parser "test"
local parser = Parser "test"
:description "A testing program. "
parser:argument "input"

View File

@@ -1,9 +1,9 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to tips", function()
describe("provides tips when data is too long", function()
it("for options", function()
local parser = argparse.parser()
local parser = Parser()
parser:option "-q" "--quiet"
assert.has_error(function() parser:parse{"--quiett=true"} end,
@@ -11,7 +11,7 @@ describe("tests related to tips", function()
end)
it("for commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:command "install"
assert.has_error(function() parser:parse{"installq"} end,
@@ -21,7 +21,7 @@ describe("tests related to tips", function()
describe("provides tips when data is too short", function()
it("for options", function()
local parser = argparse.parser()
local parser = Parser()
parser:option "-q" "--quiet"
assert.has_error(function() parser:parse{"--quet=true"} end,
@@ -29,7 +29,7 @@ describe("tests related to tips", function()
end)
it("for commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:command "install"
assert.has_error(function() parser:parse{"nstall"} end,
@@ -39,7 +39,7 @@ describe("tests related to tips", function()
describe("provides tips on substitution", function()
it("for options", function()
local parser = argparse.parser()
local parser = Parser()
parser:option "-q" "--quiet"
assert.has_error(function() parser:parse{"--qriet=true"} end,
@@ -47,7 +47,7 @@ describe("tests related to tips", function()
end)
it("for commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:command "install"
assert.has_error(function() parser:parse{"inntall"} end,
@@ -57,7 +57,7 @@ describe("tests related to tips", function()
describe("provides tips on transpositions", function()
it("for options", function()
local parser = argparse.parser()
local parser = Parser()
parser:option "-q" "--quiet"
assert.has_error(function() parser:parse{"--queit=true"} end,
@@ -65,7 +65,7 @@ describe("tests related to tips", function()
end)
it("for commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:command "install"
assert.has_error(function() parser:parse{"isntall"} end,
@@ -75,7 +75,7 @@ describe("tests related to tips", function()
describe("provides multiple tips", function()
it("for options", function()
local parser = argparse.parser()
local parser = Parser()
parser:option "-q" "--quiet"
parser:option "--quick"
@@ -84,7 +84,7 @@ describe("tests related to tips", function()
end)
it("for commands", function()
local parser = argparse.parser "name"
local parser = Parser "name"
parser:command "install"
parser:command "instant"

View File

@@ -1,14 +1,14 @@
local argparse = require "argparse"
local Parser = require "argparse"
describe("tests related to usage message generation", function()
it("creates correct usage message for empty parser", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help(false)
assert.equal(parser:prepare():get_usage(), "Usage: foo")
end)
it("creates correct usage message for arguments", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help(false)
parser:argument "first"
parser:argument "second-and-third"
@@ -25,7 +25,7 @@ describe("tests related to usage message generation", function()
end)
it("creates correct usage message for options", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help(false)
parser:flag "-q" "--quiet"
parser:option "--from"
@@ -40,7 +40,7 @@ describe("tests related to usage message generation", function()
end)
it("creates correct usage message for commands", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help(false)
parser:flag "-q" "--quiet"
local run = parser:command "run"
@@ -53,7 +53,7 @@ describe("tests related to usage message generation", function()
end)
it("creates correct usage message for subcommands", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help(false)
parser:flag "-q" "--quiet"
local run = parser:command "run"
@@ -70,7 +70,7 @@ describe("tests related to usage message generation", function()
describe("usage generation can be customized", function()
it("uses message provided by user", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:usage "Usage: obvious"
:add_help(false)
parser:flag "-q" "--quiet"
@@ -82,7 +82,7 @@ describe("tests related to usage message generation", function()
end)
it("uses per-option message provided by user", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help(false)
parser:flag "-q" "--quiet"
:usage "[-q | --quiet]"
@@ -94,7 +94,7 @@ describe("tests related to usage message generation", function()
end)
it("uses argnames provided by user", function()
local parser = argparse.parser "foo"
local parser = Parser "foo"
:add_help(false)
parser:argument "inputs"
:args "1-2"

View File

@@ -1,5 +1,3 @@
local argparse = {}
local class = require "30log"
local Declarative = {}
@@ -637,11 +635,7 @@ function Parser:parse(args)
end
local function get_option(name)
if opt_context[name] then
return opt_context[name]
else
parser:error("unknown option '%s'%s", name, get_tip(opt_context, name))
end
return parser:assert(opt_context[name], "unknown option '%s'%s", name, get_tip(opt_context, name))
end
local function handle_argument(data)
@@ -758,6 +752,4 @@ function Parser:parse(args)
return result
end
argparse.parser = Parser
return argparse
return Parser