]> git.e2factory.org Git - e2factory.git/commitdiff
policy: remove e2lib.abort()
authorTobias Ulmer <tu@emlix.com>
Tue, 16 Apr 2013 10:09:10 +0000 (12:09 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 13:58:55 +0000 (14:58 +0100)
handle_commandline_options() now return an err object

Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2-build.lua
local/e2-playground.lua
local/policy.lua

index c690852d6ddf550ae4b41db18afa783950e6a9ed..f62a03ba05a77ac653db2a44e7f70a309012d406 100644 (file)
@@ -92,9 +92,9 @@ local function e2_build(arg)
     local opts, arguments = e2option.parse(arg)
 
     -- get build mode from the command line
-    local build_mode = policy.handle_commandline_options(opts, true)
+    local build_mode, re = policy.handle_commandline_options(opts, true)
     if not build_mode then
-        return false, err.new("no build mode given")
+        return false, re
     end
 
     info, re = e2tool.collect_project_info(info)
index 65f1d879b7ca321168f2f865eb148eda1cd1852b..c91c4e0cc1575f979b8dcb5211406b41d1f5f74e 100644 (file)
@@ -53,9 +53,9 @@ local function e2_playground(arg)
 
     local opts, arguments = e2option.parse(arg)
     -- get build mode from the command line
-    local build_mode = policy.handle_commandline_options(opts, true)
+    local build_mode, re = policy.handle_commandline_options(opts, true)
     if not build_mode then
-        return false, err.new("no build mode given")
+        return false, re
     end
     info, re = e2tool.collect_project_info(info)
     if not info then
index eef4f41c981598b69b0280020affce9b33ef0951..ded305b7b6ef09f6e16213ccfcc7a93ca8c7cc93 100644 (file)
@@ -222,7 +222,8 @@ end
 function policy.handle_commandline_options(opts, use_default)
     local default_build_mode_name = "tag"
     local nmodes = 0
-    local mode = nil
+    local mode = false
+
     if opts["build-mode"] then
         nmodes = nmodes + 1
     end
@@ -243,24 +244,30 @@ function policy.handle_commandline_options(opts, use_default)
         nmodes = nmodes + 1
     end
     if nmodes > 1 then
-        e2lib.abort("Error: Multiple build modes are not supported")
+        return false, err.new("multiple build modes are not supported")
     end
     if not opts["build-mode"] and use_default then
         e2lib.warnf("WDEFAULT", "build-mode defaults to '%s'",
             default_build_mode_name)
         opts["build-mode"] = default_build_mode_name
     end
+
     if opts["build-mode"] then
         if policy.default_build_mode(opts["build-mode"]) then
             mode = policy.default_build_mode(opts["build-mode"])
         else
-            e2lib.abort("invalid build mode")
+            return false, err.new("invalid build mode")
         end
         if opts["build-mode"] == "release" then
             opts["check-remote"] = true
             opts["check"] = true
         end
     end
+
+    if not mode then
+        return false, err.new("no build mode given")
+    end
+
     return mode
 end
 
@@ -307,7 +314,6 @@ function policy.default_build_mode(mode)
             deploy = false,
         }
     else
-        -- e2lib.abort("unknown default_build_mode mode=%s", tostring(mode))
         return nil
     end
 end