diff share/lua/5.2/luarocks/list.lua @ 1132:d137f631bad5

<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
author HackBot
date Fri, 14 Dec 2012 22:24:27 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/lua/5.2/luarocks/list.lua	Fri Dec 14 22:24:27 2012 +0000
@@ -0,0 +1,38 @@
+
+--- Module implementing the LuaRocks "list" command.
+-- Lists currently installed rocks.
+module("luarocks.list", package.seeall)
+
+local search = require("luarocks.search")
+local cfg = require("luarocks.cfg")
+local util = require("luarocks.util")
+local path = require("luarocks.path")
+
+help_summary = "Lists currently installed rocks."
+help_arguments = "[--porcelain] <filter>"
+help = [[
+<filter> is a substring of a rock name to filter by.
+
+--porcelain   Produce machine-friendly output.
+]]
+
+--- Driver function for "list" command.
+-- @param filter string or nil: A substring of a rock name to filter by.
+-- @param version string or nil: a version may also be passed.
+-- @return boolean: True if succeeded, nil on errors.
+function run(...)
+   local flags, filter, version = util.parse_flags(...)
+   local results = {}
+   local query = search.make_query(filter and filter:lower() or "", version)
+   query.exact_name = false
+   local trees = cfg.rocks_trees
+   if flags["tree"] then
+      trees = { flags["tree"] }
+   end
+   for _, tree in ipairs(trees) do
+      search.manifest_search(results, path.rocks_dir(tree), query)
+   end
+   util.title("Installed rocks:", flags["porcelain"])
+   search.print_results(results, flags["porcelain"])
+   return true
+end