From: Gordon Hecker Date: Wed, 21 Oct 2009 13:18:39 +0000 (+0200) Subject: allow overriding command line options by initializing before the X-Git-Tag: e2factory-2.3.2rc1~43 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=d53b27e132a84b9237449fa8ee0ca983a499004c;p=e2factory.git allow overriding command line options by initializing before the call to e2option.parse() Signed-off-by: Gordon Hecker --- 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"}