aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-10-17 17:39:43 -0300
committerHisham Muhammad <hisham@gobolinux.org>2012-10-17 17:39:43 -0300
commit1f27702935b9bba1c0c3240a52a7ecaeca0ea81c (patch)
tree9c717ad2f5f7629ac3b1520d1e600936547e0ed1 /src
parent330ef7b69185a0e8a13edf6c2a401bd775567022 (diff)
parent960c8b1f79837ea305ef93cb128b22ed96565c18 (diff)
downloadluarocks-1f27702935b9bba1c0c3240a52a7ecaeca0ea81c.tar.gz
luarocks-1f27702935b9bba1c0c3240a52a7ecaeca0ea81c.tar.bz2
luarocks-1f27702935b9bba1c0c3240a52a7ecaeca0ea81c.zip
Merge branch 'master' into multitree
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/download.lua4
-rw-r--r--src/luarocks/install.lua4
-rw-r--r--src/luarocks/list.lua7
-rw-r--r--src/luarocks/search.lua44
-rw-r--r--src/luarocks/util.lua8
-rw-r--r--src/luarocks/validate.lua8
6 files changed, 34 insertions, 41 deletions
diff --git a/src/luarocks/download.lua b/src/luarocks/download.lua
index ae835bf2..0012cb18 100644
--- a/src/luarocks/download.lua
+++ b/src/luarocks/download.lua
@@ -50,9 +50,7 @@ function download(arch, name, version, all)
50 return all_ok, any_err 50 return all_ok, any_err
51 else 51 else
52 util.printerr("Multiple search results were returned.") 52 util.printerr("Multiple search results were returned.")
53 util.printout() 53 util.title("Search results:")
54 util.printout("Search results:")
55 util.printout("---------------")
56 search.print_results(results) 54 search.print_results(results)
57 return nil, "Please narrow your query or use --all." 55 return nil, "Please narrow your query or use --all."
58 end 56 end
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua
index a940d356..0ffb95ef 100644
--- a/src/luarocks/install.lua
+++ b/src/luarocks/install.lua
@@ -146,9 +146,7 @@ function run(...)
146 else 146 else
147 util.printout() 147 util.printout()
148 util.printerr("Could not determine which rock to install.") 148 util.printerr("Could not determine which rock to install.")
149 util.printout() 149 util.title("Search results:")
150 util.printout("Search results:")
151 util.printout("---------------")
152 search.print_results(results) 150 search.print_results(results)
153 return nil, (next(results) and "Please narrow your query." or "No results found.") 151 return nil, (next(results) and "Please narrow your query." or "No results found.")
154 end 152 end
diff --git a/src/luarocks/list.lua b/src/luarocks/list.lua
index 1943f932..f56fc7e9 100644
--- a/src/luarocks/list.lua
+++ b/src/luarocks/list.lua
@@ -26,10 +26,7 @@ function run(...)
26 for _, tree in ipairs(cfg.rocks_trees) do 26 for _, tree in ipairs(cfg.rocks_trees) do
27 search.manifest_search(results, path.rocks_dir(tree), query) 27 search.manifest_search(results, path.rocks_dir(tree), query)
28 end 28 end
29 util.printout() 29 util.title("Installed rocks:", flags["porcelain"])
30 util.printout("Installed rocks:") 30 search.print_results(results, flags["porcelain"])
31 util.printout("----------------")
32 util.printout()
33 search.print_results(results, false)
34 return true 31 return true
35end 32end
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua
index 692004ae..7db88d74 100644
--- a/src/luarocks/search.lua
+++ b/src/luarocks/search.lua
@@ -282,25 +282,27 @@ end
282--- Print a list of rocks/rockspecs on standard output. 282--- Print a list of rocks/rockspecs on standard output.
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 porcelain boolean or nil: A flag to force machine-friendly output.
286function print_results(results, show_repo) 286function print_results(results, porcelain)
287 assert(type(results) == "table") 287 assert(type(results) == "table")
288 assert(type(show_repo) == "boolean" or not show_repo) 288 assert(type(porcelain) == "boolean" or not porcelain)
289 -- Force display of repo location for the time being
290 show_repo = true -- show_repo == nil and true or show_repo
291 289
292 for package, versions in util.sortedpairs(results) do 290 for package, versions in util.sortedpairs(results) do
293 util.printout(package) 291 if not porcelain then
294 for version, repositories in util.sortedpairs(versions, deps.compare_versions) do 292 util.printout(package)
295 if show_repo then 293 end
296 for _, repo in ipairs(repositories) do 294 for version, repos in util.sortedpairs(versions, deps.compare_versions) do
295 for _, repo in ipairs(repos) do
296 if porcelain then
297 util.printout(package, version, repo.arch, repo.repo)
298 else
297 util.printout(" "..version.." ("..repo.arch..") - "..repo.repo) 299 util.printout(" "..version.." ("..repo.arch..") - "..repo.repo)
298 end 300 end
299 else
300 util.printout(" "..version)
301 end 301 end
302 end 302 end
303 util.printout() 303 if not porcelain then
304 util.printout()
305 end
304 end 306 end
305end 307end
306 308
@@ -369,22 +371,16 @@ function run(...)
369 local query = make_query(name:lower(), version) 371 local query = make_query(name:lower(), version)
370 query.exact_name = false 372 query.exact_name = false
371 local results, err = search_repos(query) 373 local results, err = search_repos(query)
372 util.printout() 374 local porcelain = flags["porcelain"]
373 util.printout("Search results:") 375 util.title("Search results:", porcelain, "=")
374 util.printout("===============")
375 util.printout()
376 local sources, binaries = split_source_and_binary_results(results) 376 local sources, binaries = split_source_and_binary_results(results)
377 if next(sources) and not flags["binary"] then 377 if next(sources) and not flags["binary"] then
378 util.printout("Rockspecs and source rocks:") 378 util.title("Rockspecs and source rocks:", porcelain)
379 util.printout("---------------------------") 379 print_results(sources, porcelain)
380 util.printout()
381 print_results(sources, true)
382 end 380 end
383 if next(binaries) and not flags["source"] then 381 if next(binaries) and not flags["source"] then
384 util.printout("Binary and pure-Lua rocks:") 382 util.title("Binary and pure-Lua rocks:", porcelain)
385 util.printout("--------------------------") 383 print_results(binaries, porcelain)
386 util.printout()
387 print_results(binaries, true)
388 end 384 end
389 return true 385 return true
390end 386end
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 67a3778a..c6e0c592 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -299,6 +299,14 @@ function warning(msg)
299 printerr("Warning: "..msg) 299 printerr("Warning: "..msg)
300end 300end
301 301
302function title(msg, porcelain, underline)
303 if porcelain then return end
304 printout()
305 printout(msg)
306 printout((underline or "-"):rep(#msg))
307 printout()
308end
309
302-- from http://lua-users.org/wiki/SplitJoin 310-- from http://lua-users.org/wiki/SplitJoin
303-- by PhilippeLhoste 311-- by PhilippeLhoste
304function split_string(str, delim, maxNb) 312function split_string(str, delim, maxNb)
diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua
index fb6a78ad..1e1e69e1 100644
--- a/src/luarocks/validate.lua
+++ b/src/luarocks/validate.lua
@@ -124,9 +124,7 @@ local function validate(repo, flags)
124 fs.delete(sandbox) 124 fs.delete(sandbox)
125 end 125 end
126 restore_settings(settings) 126 restore_settings(settings)
127 util.printout() 127 util.title("Results:")
128 util.printout("Results:")
129 util.printout("--------")
130 util.printout("OK: "..tostring(#results.ok)) 128 util.printout("OK: "..tostring(#results.ok))
131 for _, entry in ipairs(results.ok) do 129 for _, entry in ipairs(results.ok) do
132 util.printout(entry.file) 130 util.printout(entry.file)
@@ -141,9 +139,7 @@ local function validate(repo, flags)
141 end 139 end
142 end 140 end
143 141
144 util.printout() 142 util.title("Summary:")
145 util.printout("Summary:")
146 util.printout("--------")
147 local total = 0 143 local total = 0
148 for errcode, errors in pairs(results) do 144 for errcode, errors in pairs(results) do
149 util.printout(errcode..": "..tostring(#errors)) 145 util.printout(errcode..": "..tostring(#errors))