From d53b27e132a84b9237449fa8ee0ca983a499004c Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Wed, 21 Oct 2009 15:18:39 +0200 Subject: [PATCH] allow overriding command line options by initializing before the call to e2option.parse() Signed-off-by: Gordon Hecker --- generic/e2option.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generic/e2option.lua b/generic/e2option.lua index 4361635..20b07d5 100644 --- a/generic/e2option.lua +++ b/generic/e2option.lua @@ -69,6 +69,9 @@ e2option.aliases = {} -- @param category string: category name -- @return nil function e2option.flag(name, doc, func, category) + if options[ name ] then + return false, new_error("option exists: %s", name) + end options[ name ] = {type = "flag", documentation = doc or "", name = name, proc=func, default = true, category = category} @@ -83,6 +86,9 @@ end -- @param argname string: argument name used in documentation (optional) -- @return nil function e2option.option(name, doc, default, func, argname) + if options[ name ] then + return false, new_error("option exists: %s", name) + end options[ name ] = {type = "option", documentation = doc or "", name = name, proc=func, default=default or true, argumentname=argname or "ARGUMENT"} -- 2.39.5