]> git.e2factory.org Git - e2factory.git/commitdiff
allow overriding command line options by initializing before the
authorGordon Hecker <gh@emlix.com>
Wed, 21 Oct 2009 13:18:39 +0000 (15:18 +0200)
committerGordon Hecker <gh@emlix.com>
Wed, 21 Oct 2009 13:18:59 +0000 (15:18 +0200)
call to e2option.parse()

Signed-off-by: Gordon Hecker <gh@emlix.com>
generic/e2option.lua

index 43616353f16fe24f83dce532f912107ae04ddd74..20b07d599d2b9385600703cc415c5d8773fc65e0 100644 (file)
@@ -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"}