diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/bin/luarocks | 1 | ||||
-rw-r--r-- | src/luarocks/search.lua | 3 | ||||
-rw-r--r-- | src/luarocks/show.lua | 5 | ||||
-rw-r--r-- | src/luarocks/util.lua | 27 |
4 files changed, 34 insertions, 2 deletions
diff --git a/src/bin/luarocks b/src/bin/luarocks index fd0c1d9c..5da4bc25 100755 --- a/src/bin/luarocks +++ b/src/bin/luarocks | |||
@@ -17,5 +17,6 @@ commands.remove = require("luarocks.remove") | |||
17 | commands.make = require("luarocks.make") | 17 | commands.make = require("luarocks.make") |
18 | commands.download = require("luarocks.download") | 18 | commands.download = require("luarocks.download") |
19 | commands.path = require("luarocks.path") | 19 | commands.path = require("luarocks.path") |
20 | commands.show = require("luarocks.show") | ||
20 | 21 | ||
21 | command_line.run_command(...) | 22 | command_line.run_command(...) |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 6303eb8c..97b86a45 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -283,8 +283,9 @@ end | |||
283 | -- @param results table: A table where keys are package names and versions | 283 | -- @param results table: A table where keys are package names and versions |
284 | -- are tables matching version strings to an array of rocks servers. | 284 | -- are tables matching version strings to an array of rocks servers. |
285 | -- @param show_repo boolean or nil: Whether to show repository | 285 | -- @param show_repo boolean or nil: Whether to show repository |
286 | -- @param long boolean or nil: Whether to show module files | ||
286 | -- information or not. Default is true. | 287 | -- information or not. Default is true. |
287 | function print_results(results, show_repo) | 288 | function print_results(results, show_repo, long) |
288 | assert(type(results) == "table") | 289 | assert(type(results) == "table") |
289 | assert(type(show_repo) == "boolean" or not show_repo) | 290 | assert(type(show_repo) == "boolean" or not show_repo) |
290 | -- Force display of repo location for the time being | 291 | -- Force display of repo location for the time being |
diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index 60672fc5..fcdffb9c 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua | |||
@@ -23,6 +23,8 @@ With these flags, return only the desired information: | |||
23 | --deps packages this package depends on | 23 | --deps packages this package depends on |
24 | --rockspec the full path of the rockspec file | 24 | --rockspec the full path of the rockspec file |
25 | --mversion the package version | 25 | --mversion the package version |
26 | --tree local tree where rock is installed | ||
27 | --rock-dir data directory of the installed rock | ||
26 | ]] | 28 | ]] |
27 | 29 | ||
28 | local function keys_as_string(t, sep) | 30 | local function keys_as_string(t, sep) |
@@ -97,7 +99,8 @@ function run(...) | |||
97 | if not manifest then return nil,err end | 99 | if not manifest then return nil,err end |
98 | local minfo = manifest.repository[name][version][1] | 100 | local minfo = manifest.repository[name][version][1] |
99 | 101 | ||
100 | if flags["dir"] then print(directory) | 102 | if flags["tree"] then print(repo) |
103 | elseif flags["rock-dir"] then print(directory) | ||
101 | elseif flags["home"] then print(descript.homepage) | 104 | elseif flags["home"] then print(descript.homepage) |
102 | elseif flags["modules"] then print(keys_as_string(minfo.modules)) | 105 | elseif flags["modules"] then print(keys_as_string(minfo.modules)) |
103 | elseif flags["deps"] then print(keys_as_string(minfo.dependencies)) | 106 | elseif flags["deps"] then print(keys_as_string(minfo.dependencies)) |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 164dd260..ed70b2ba 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -243,6 +243,33 @@ function starts_with(s, prefix) | |||
243 | return s:sub(1,#prefix) == prefix | 243 | return s:sub(1,#prefix) == prefix |
244 | end | 244 | end |
245 | 245 | ||
246 | -- from http://lua-users.org/wiki/SplitJoin | ||
247 | -- by PhilippeLhoste | ||
248 | function split_string(str, delim, maxNb) | ||
249 | -- Eliminate bad cases... | ||
250 | if string.find(str, delim) == nil then | ||
251 | return { str } | ||
252 | end | ||
253 | if maxNb == nil or maxNb < 1 then | ||
254 | maxNb = 0 -- No limit | ||
255 | end | ||
256 | local result = {} | ||
257 | local pat = "(.-)" .. delim .. "()" | ||
258 | local nb = 0 | ||
259 | local lastPos | ||
260 | for part, pos in string.gfind(str, pat) do | ||
261 | nb = nb + 1 | ||
262 | result[nb] = part | ||
263 | lastPos = pos | ||
264 | if nb == maxNb then break end | ||
265 | end | ||
266 | -- Handle the last field | ||
267 | if nb ~= maxNb then | ||
268 | result[nb + 1] = string.sub(str, lastPos) | ||
269 | end | ||
270 | return result | ||
271 | end | ||
272 | |||
246 | --[[ | 273 | --[[ |
247 | Author: Julio Manuel Fernandez-Diaz | 274 | Author: Julio Manuel Fernandez-Diaz |
248 | Date: January 12, 2007 | 275 | Date: January 12, 2007 |