diff options
author | Peter Melnichenko <mpeterval@gmail.com> | 2016-06-03 12:07:54 +0300 |
---|---|---|
committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-06-03 12:07:54 +0300 |
commit | a84d179f18b51190a27f6528aa016c6746c2c6c0 (patch) | |
tree | d918624607d81fffbe12e75cbd7ca9a75b39349f | |
parent | d55041dbc477000d0aa8a1585824958b0ade66a1 (diff) | |
download | luarocks-a84d179f18b51190a27f6528aa016c6746c2c6c0.tar.gz luarocks-a84d179f18b51190a27f6528aa016c6746c2c6c0.tar.bz2 luarocks-a84d179f18b51190a27f6528aa016c6746c2c6c0.zip |
Get rid of util.forward_flags
Use 'commands' functions directly.
-rw-r--r-- | src/luarocks/install.lua | 4 | ||||
-rw-r--r-- | src/luarocks/util.lua | 32 |
2 files changed, 2 insertions, 34 deletions
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index d961f525..acbf584a 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -160,7 +160,7 @@ function install.command(flags, name, version) | |||
160 | 160 | ||
161 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then | 161 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then |
162 | local build = require("luarocks.build") | 162 | local build = require("luarocks.build") |
163 | return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode", "only-deps", "force", "force-fast")) | 163 | return build.command(flags, name) |
164 | elseif name:match("%.rock$") then | 164 | elseif name:match("%.rock$") then |
165 | if flags["only-deps"] then | 165 | if flags["only-deps"] then |
166 | ok, err = install.install_binary_rock_deps(name, deps.get_deps_mode(flags)) | 166 | ok, err = install.install_binary_rock_deps(name, deps.get_deps_mode(flags)) |
@@ -181,7 +181,7 @@ function install.command(flags, name, version) | |||
181 | return nil, err | 181 | return nil, err |
182 | end | 182 | end |
183 | util.printout("Installing "..url) | 183 | util.printout("Installing "..url) |
184 | return install.run(url, util.forward_flags(flags)) | 184 | return install.command(flags, url) |
185 | end | 185 | end |
186 | end | 186 | end |
187 | 187 | ||
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 6aff5324..532bea8b 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -196,38 +196,6 @@ function util.parse_flags(...) | |||
196 | return flags, unpack(out) | 196 | return flags, unpack(out) |
197 | end | 197 | end |
198 | 198 | ||
199 | --- Build a sequence of flags for forwarding from one command to | ||
200 | -- another (for example, from "install" to "build"). | ||
201 | -- @param flags table: A table of parsed flags | ||
202 | -- @param ... string...: A variable number of flags to be checked | ||
203 | -- in the flags table. If no flags are passed as varargs, the | ||
204 | -- entire flags table is forwarded. | ||
205 | -- @return string... A variable number of strings | ||
206 | function util.forward_flags(flags, ...) | ||
207 | assert(type(flags) == "table") | ||
208 | local out = {} | ||
209 | local filter = select('#', ...) | ||
210 | local function add_flag(flagname) | ||
211 | if flags[flagname] then | ||
212 | if flags[flagname] == true then | ||
213 | table.insert(out, "--"..flagname) | ||
214 | else | ||
215 | table.insert(out, "--"..flagname.."="..flags[flagname]) | ||
216 | end | ||
217 | end | ||
218 | end | ||
219 | if filter > 0 then | ||
220 | for i = 1, filter do | ||
221 | add_flag(select(i, ...)) | ||
222 | end | ||
223 | else | ||
224 | for flagname, _ in pairs(flags) do | ||
225 | add_flag(flagname) | ||
226 | end | ||
227 | end | ||
228 | return unpack(out) | ||
229 | end | ||
230 | |||
231 | -- Adds legacy 'run' function to a command module. | 199 | -- Adds legacy 'run' function to a command module. |
232 | -- @param command table: command module with 'command' function, | 200 | -- @param command table: command module with 'command' function, |
233 | -- the added 'run' function calls it after parseing command-line arguments. | 201 | -- the added 'run' function calls it after parseing command-line arguments. |