diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-17 15:12:23 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-17 15:12:23 -0300 |
commit | 960c8b1f79837ea305ef93cb128b22ed96565c18 (patch) | |
tree | 526d229567d9f01ec09a3d414bb41313d1a1323c /src | |
parent | 9b254a77abd872ba707027059eb53a51b60f231a (diff) | |
download | luarocks-960c8b1f79837ea305ef93cb128b22ed96565c18.tar.gz luarocks-960c8b1f79837ea305ef93cb128b22ed96565c18.tar.bz2 luarocks-960c8b1f79837ea305ef93cb128b22ed96565c18.zip |
Cleanup display of titles, simplify porcelain a bit.
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/download.lua | 4 | ||||
-rw-r--r-- | src/luarocks/install.lua | 4 | ||||
-rw-r--r-- | src/luarocks/list.lua | 13 | ||||
-rw-r--r-- | src/luarocks/search.lua | 30 | ||||
-rw-r--r-- | src/luarocks/util.lua | 8 | ||||
-rw-r--r-- | src/luarocks/validate.lua | 8 |
6 files changed, 21 insertions, 46 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 6b5ea85f..708d6abe 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -141,9 +141,7 @@ function run(...) | |||
141 | else | 141 | else |
142 | util.printout() | 142 | util.printout() |
143 | util.printerr("Could not determine which rock to install.") | 143 | util.printerr("Could not determine which rock to install.") |
144 | util.printout() | 144 | util.title("Search results:") |
145 | util.printout("Search results:") | ||
146 | util.printout("---------------") | ||
147 | search.print_results(results) | 145 | search.print_results(results) |
148 | return nil, (next(results) and "Please narrow your query." or "No results found.") | 146 | return nil, (next(results) and "Please narrow your query." or "No results found.") |
149 | end | 147 | end |
diff --git a/src/luarocks/list.lua b/src/luarocks/list.lua index f9aa5fe1..f56fc7e9 100644 --- a/src/luarocks/list.lua +++ b/src/luarocks/list.lua | |||
@@ -26,16 +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 | -- machine-readable output | 29 | util.title("Installed rocks:", flags["porcelain"]) |
30 | if flags["porcelain"] then | 30 | search.print_results(results, flags["porcelain"]) |
31 | search.print_results(results, true) | ||
32 | -- pretty human-readable output | ||
33 | else | ||
34 | util.printout() | ||
35 | util.printout("Installed rocks:") | ||
36 | util.printout("----------------") | ||
37 | util.printout() | ||
38 | search.print_results(results) | ||
39 | end | ||
40 | return true | 31 | return true |
41 | end | 32 | end |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index eeb9c20c..7db88d74 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -295,11 +295,8 @@ function print_results(results, porcelain) | |||
295 | for _, repo in ipairs(repos) do | 295 | for _, repo in ipairs(repos) do |
296 | if porcelain then | 296 | if porcelain then |
297 | util.printout(package, version, repo.arch, repo.repo) | 297 | util.printout(package, version, repo.arch, repo.repo) |
298 | --for k, v in pairs(repo) do print(k, v) end | ||
299 | else | 298 | else |
300 | util.printout( | 299 | util.printout(" "..version.." ("..repo.arch..") - "..repo.repo) |
301 | " "..version.." ("..repo.arch..") - "..repo.repo | ||
302 | ) | ||
303 | end | 300 | end |
304 | end | 301 | end |
305 | end | 302 | end |
@@ -374,29 +371,16 @@ function run(...) | |||
374 | local query = make_query(name:lower(), version) | 371 | local query = make_query(name:lower(), version) |
375 | query.exact_name = false | 372 | query.exact_name = false |
376 | local results, err = search_repos(query) | 373 | local results, err = search_repos(query) |
377 | -- N.B. --porcelain forces machine-readable output | 374 | local porcelain = flags["porcelain"] |
378 | if not flags["porcelain"] then | 375 | util.title("Search results:", porcelain, "=") |
379 | util.printout() | ||
380 | util.printout("Search results:") | ||
381 | util.printout("===============") | ||
382 | util.printout() | ||
383 | end | ||
384 | local sources, binaries = split_source_and_binary_results(results) | 376 | local sources, binaries = split_source_and_binary_results(results) |
385 | if next(sources) and not flags["binary"] then | 377 | if next(sources) and not flags["binary"] then |
386 | if not flags["porcelain"] then | 378 | util.title("Rockspecs and source rocks:", porcelain) |
387 | util.printout("Rockspecs and source rocks:") | 379 | print_results(sources, porcelain) |
388 | util.printout("---------------------------") | ||
389 | util.printout() | ||
390 | end | ||
391 | print_results(sources, flags["porcelain"]) | ||
392 | end | 380 | end |
393 | if next(binaries) and not flags["source"] then | 381 | if next(binaries) and not flags["source"] then |
394 | if not flags["porcelain"] then | 382 | util.title("Binary and pure-Lua rocks:", porcelain) |
395 | util.printout("Binary and pure-Lua rocks:") | 383 | print_results(binaries, porcelain) |
396 | util.printout("--------------------------") | ||
397 | util.printout() | ||
398 | end | ||
399 | print_results(binaries, flags["porcelain"]) | ||
400 | end | 384 | end |
401 | return true | 385 | return true |
402 | end | 386 | end |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 512644c6..de7a43a2 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) |
300 | end | 300 | end |
301 | 301 | ||
302 | function title(msg, porcelain, underline) | ||
303 | if porcelain then return end | ||
304 | printout() | ||
305 | printout(msg) | ||
306 | printout((underline or "-"):rep(#msg)) | ||
307 | printout() | ||
308 | end | ||
309 | |||
302 | -- from http://lua-users.org/wiki/SplitJoin | 310 | -- from http://lua-users.org/wiki/SplitJoin |
303 | -- by PhilippeLhoste | 311 | -- by PhilippeLhoste |
304 | function split_string(str, delim, maxNb) | 312 | function split_string(str, delim, maxNb) |
diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua index 03e90ecf..ed12f8f0 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)) |