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,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
}