From 3a80e0179bdbe4e6d59c293771350ca246d43f52 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Tue, 18 Feb 2014 15:35:58 +0400 Subject: [PATCH] :pparse() should still raise an error if it is caused by misconfiguration --- spec/pparse_spec.lua | 7 +++++++ src/argparse.lua | 1 + 2 files changed, 8 insertions(+) diff --git a/spec/pparse_spec.lua b/spec/pparse_spec.lua index e0516ac..4a79c00 100644 --- a/spec/pparse_spec.lua +++ b/spec/pparse_spec.lua @@ -16,4 +16,11 @@ describe("tests related to :pparse()", function() assert.is_false(ok) assert.equal("too few arguments", errmsg) end) + + it("still raises an error if it is caused by misconfiguration", function() + local parser = Parser() + parser:option "--foo" + :count "a lot" + assert.has_error(function() parser:pparse{} end) + end) end) diff --git a/src/argparse.lua b/src/argparse.lua index 93551f1..bad0fc1 100644 --- a/src/argparse.lua +++ b/src/argparse.lua @@ -778,6 +778,7 @@ function Parser:pparse(args) if ok then return true, result else + assert(errmsg, result) return false, errmsg end end