]> git.e2factory.org Git - e2factory.git/commitdiff
Remove opts.arguments and access arguments directly
authorTobias Ulmer <tu@emlix.com>
Mon, 20 Aug 2012 09:37:28 +0000 (11:37 +0200)
committerTobias Ulmer <tu@emlix.com>
Tue, 26 Feb 2013 18:07:06 +0000 (19:07 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2option.lua
global/e2-create-project.lua
global/e2-fetch-project.lua
global/e2-install-e2.lua
local/build.lua
local/cf.lua
local/dlist.lua
local/fetch-sources.lua
local/ls-project.lua
local/new-source.lua
local/playground.lua

index 2426a00aa62e6ea0eec1a1ff38cdbc155765758f..ca65e679257aa80331b9dcb6c2493085b5c86f4c 100644 (file)
@@ -318,9 +318,6 @@ function e2option.parse(args)
     defaultoptions()
     local opts = {}
     local vals = {}
-    -- arguments is a special option containing all additional arguments that
-    -- are not parsed. XXX: Remove this if possible.
-    opts["arguments"] = vals
 
     userdefaultoptions(opts)
 
index a4a9b59f679520d5b07ffc4f4713a02c73875623..2c7844982f68ba75d5ebd3448d6accfcd28ebf7f 100644 (file)
@@ -43,7 +43,7 @@ Create a new project and store it on <server> in <location>.
 e2option.documentation = string.format(doc,
                                e2lib.globals.default_projects_server)
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 local rc, e = e2lib.read_global_config()
 if not rc then
   e2lib.abort(e)
@@ -76,11 +76,11 @@ else
   e2lib.globals.local_e2_tag =  config.site.e2_tag
 end
 
-if #opts.arguments ~= 1 then
+if #arguments ~= 1 then
   e2option.usage(1)
 end
 
-local sl, re = e2lib.parse_server_location(opts.arguments[1],
+local sl, re = e2lib.parse_server_location(arguments[1],
                                        e2lib.globals.default_projects_server)
 if not sl then
   e2lib.abort(e:cat(re))
index 6ee572fd3bd0b48a5666687bae446c41e008e40a..005c69b5c1eabc48eaa966da09162c132a212e18 100644 (file)
@@ -47,7 +47,7 @@ e2option.documentation = string.format(doc,
 e2option.option("branch", "retrieve a specific project branch")
 e2option.option("tag", "retrieve a specific project tag")
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 local rc, re = e2lib.read_global_config()
 if not rc then
   e2lib.abort(e:cat(re))
@@ -65,14 +65,14 @@ end
 
 -- standard global tool setup finished
 
-if #opts.arguments < 1 then
+if #arguments < 1 then
   e2lib.abort("specify path to a project to fetch")
 end
-if #opts.arguments > 2 then
+if #arguments > 2 then
   e2lib.abort("too many arguments")
 end
 
-local sl, re = e2lib.parse_server_location(opts.arguments[1],
+local sl, re = e2lib.parse_server_location(arguments[1],
                                        e2lib.globals.default_projects_server)
 if not sl then
   e2lib.abort(e:cat(re))
@@ -82,8 +82,8 @@ local p = {}
 p.server = sl.server
 p.location = sl.location
 p.name = e2lib.basename(p.location)
-if opts.arguments[2] then
-       p.destdir = opts.arguments[2]
+if arguments[2] then
+       p.destdir = arguments[2]
 else
        p.destdir = p.name
 end
index d86357818327edf992bca347740caae4df56a9c7..1f24195a2077495ac8eb63391edc22c493b85867 100644 (file)
@@ -39,7 +39,7 @@ usage: e2-install-e2 [OPTION ...]
 Installs local tools in project environment.
 ]]
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 
 local root = e2lib.locate_project_root()
 if not root then
@@ -71,7 +71,7 @@ end
 
 -- standard global tool setup finished
 
-if #opts.arguments > 0 then
+if #arguments > 0 then
   e2option.usage(1)
 end
 
index ff97d4532e275b653b1585231cd926f534eb9968..987f77d621051904815ee88eb8d99f8e29e2e1a1 100644 (file)
@@ -92,7 +92,7 @@ e2option.option("disable-writeback", "disable writeback for server", nil,
 e2option.option("enable-writeback", "enable writeback for server", nil,
                                                enable_writeback, "SERVER")
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 
 -- get build mode from the command line
 local build_mode = policy.handle_commandline_options(opts, true)
@@ -121,8 +121,8 @@ if opts["all"] then
        for r,_ in pairs(info.results) do
                table.insert(results, r)
        end
-elseif #opts.arguments > 0 then
-       for i,r in ipairs(opts.arguments) do
+elseif #arguments > 0 then
+       for i,r in ipairs(arguments) do
                table.insert(results, r)
        end
 end
@@ -148,7 +148,7 @@ if playground then
   if opts.all then
     e2lib.abort("--all and --playground are mutually exclusive")
   end
-  if #opts.arguments ~= 1 then
+  if #arguments ~= 1 then
     e2lib.abort("please select one single result for the playground")
   end
 end
index fcb362df9afb77ccc38939de54832f9f3538be09..f478808abfe84f8f6cd574619ef3416cde308050 100644 (file)
@@ -57,7 +57,7 @@ e.g.: eb <name> is equivalent to editbuildscript <name>
 modify and create configuration files
 ]]
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 
 -- initialize some basics in the info structure without actually loading
 -- the project configuration.
@@ -212,8 +212,8 @@ commands.esource = editsource
 
 local i = 1
 local match = {}
-local cmd = opts.arguments[1]
-if #opts.arguments < 1 then
+local cmd = arguments[1]
+if #arguments < 1 then
        e2option.usage()
        e2lib.finish(1)
 end
@@ -224,7 +224,7 @@ for c,f in pairs(commands) do
 end
 if #match == 1 then
        local a = {}
-       for _,o in ipairs(opts.arguments) do
+       for _,o in ipairs(arguments) do
                table.insert(a, o)
        end
        local f = commands[match[1]]
index 570b933eb805e4f610596b2c50ce70277e89a0e4..44d16bc65648a91276349a7143ca39504de65913 100644 (file)
@@ -45,13 +45,13 @@ for the given result show those results which it depends on
 ]]
 
 e2option.flag("recursive", "show indirect dependencies, too")
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 
-if #opts.arguments == 0 then
+if #arguments == 0 then
   e2lib.abort("no result given - enter `e2-dlist --help' for usage information")
-elseif #opts.arguments ~= 1 then e2option.usage(1) end
+elseif #arguments ~= 1 then e2option.usage(1) end
 
-local result = opts.arguments[1]
+local result = arguments[1]
 info, re = e2tool.collect_project_info(info)
 if not info then
   e2lib.abort(re)
index 3d5fbed9a6c9920558f4732b5991fe3a0ba42277..ef53f27ec25966f67d8751cfd47029c16b69b162 100644 (file)
@@ -73,7 +73,7 @@ e2option.flag("update", "update selected source")
 e2option.flag("source", "select sources by source names (default)")
 e2option.flag("result", "select sources by result names")
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 info, re = e2tool.collect_project_info(info)
 if not info then
   e2lib.abort(re)
@@ -90,7 +90,7 @@ end
 if opts.all then
   e2lib.warn("WOTHER", "--all selects all sources, even files sources")
 end
-if #opts.arguments > 0 then
+if #arguments > 0 then
   opts.selection = true
 end
 if not (opts.scm or opts.files or opts.chroot or opts.selection
@@ -192,8 +192,8 @@ end
 
 local sel = {} -- selected sources
 
-if #opts.arguments > 0 then
-  for _, x in pairs(opts.arguments) do
+if #arguments > 0 then
+  for _, x in pairs(arguments) do
     if info.sources[x] and not opts.result then
       e2lib.log(3, "is regarded as source: " .. x)
       sel[x] = x
index 465958091af9dea72f4858f195e04edaffbecf9b..7381e880ad9e2c8c0bceb0bb68a4e1a9acfe56c1 100644 (file)
@@ -50,7 +50,7 @@ e2option.flag("dot-sources", "generate dot(1) graph with sources included")
 e2option.flag("swap", "swap arrow directions in dot graph")
 e2option.flag("all", "show unused results and sources, too")
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 
 info, re = e2tool.collect_project_info(info)
 if not info then
@@ -66,8 +66,8 @@ if opts.all then
   for r, _ in pairs(info.results) do
     table.insert(results, r)
   end
-elseif #opts.arguments > 0 then
-  for _, r in ipairs(opts.arguments) do
+elseif #arguments > 0 then
+  for _, r in ipairs(arguments) do
     if info.results[r] then
       table.insert(results, r)
     else
index 3c01e787785799b5c5f9319a1329c9d1f8f9e5b5..caf4184c0cf94fd59e2d0f68905ed4bb358a3a5c 100644 (file)
@@ -66,7 +66,7 @@ e2option.flag("git", "create a git repository")
 e2option.flag("files", "create a new file on a files server")
 e2option.option("server", "specify server")
 e2option.flag("no-checksum", "don't verify checksum")
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 
 -- read a checksum from a file
 -- @param checksum_file string: the file containing the checksums
@@ -257,7 +257,7 @@ if not info then
 end
 
 if opts.git then
-  if #opts.arguments ~= 1 then
+  if #arguments ~= 1 then
     e2lib.abort("<name> argument required")
   end
   -- remote
@@ -265,7 +265,7 @@ if opts.git then
   if opts["server"] then
     rserver = opts["server"]
   end
-  local name = opts.arguments[1]
+  local name = arguments[1]
   local rlocation = string.format("%s/git/%s.git", info.project_location, name)
   -- local
   local lserver = info.root_server_name
@@ -279,15 +279,15 @@ if opts.git then
   e2lib.log(1,
     "See e2-new-source(1) to see how to go on")
 elseif opts.files then
-  local location = opts.arguments[1]
+  local location = arguments[1]
   local sl, e = e2lib.parse_server_location(location, info.default_files_server)
   if not sl then
     e2lib.abort(e)
   end
   local server = sl.server
   local location = sl.location
-  local source_file = opts.arguments[2]
-  local checksum_file = opts.arguments[3]
+  local source_file = arguments[2]
+  local checksum_file = arguments[3]
   local checksum_file_format = opts["checksum-file"]
   local no_checksum = opts["no-checksum"]
   if not no_checksum and not checksum_file then
index 96cb94aa43fb6403f44cb5dcefc264ce00159994..dc5b4407f5c48c19806cd4aa7d4fd890b76148d4 100644 (file)
@@ -51,7 +51,7 @@ e2option.option("command","execute command in chroot")
 e2option.flag("runinit","run init files automatically")
 e2option.flag("showpath", "prints the path of the build directory inside the chroot to stdout" )
 
-local opts = e2option.parse(arg)
+local opts, arguments = e2option.parse(arg)
 -- get build mode from the command line
 local build_mode = policy.handle_commandline_options(opts, true)
 if not build_mode then
@@ -66,11 +66,11 @@ if not rc then
   e2lib.abort(re)
 end
 
-if #opts.arguments ~= 1 then
+if #arguments ~= 1 then
   e2option.usage(1)
 end
 
-r = opts.arguments[1]
+r = arguments[1]
 
 -- apply the standard build mode to all results
 for _,res in pairs(info.results) do