File size: 1,040 Bytes
7e9dc27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

--- @module luarocks.which_cmd
-- Driver for the `luarocks which` command.
local which_cmd = {}

local loader = require("luarocks.loader")
local cfg = require("luarocks.core.cfg")
local util = require("luarocks.util")

which_cmd.help_summary = "Tell which file corresponds to a given module name."
which_cmd.help_arguments = "<modname>"
which_cmd.help = [[

Given a module name like "foo.bar", output which file would be loaded to resolve

that module by luarocks.loader, like "/usr/local/lua/]]..cfg.lua_version..[[/foo/bar.lua".

]]

--- Driver function for "lua" command.
-- @return boolean This function terminates the interpreter.
function which_cmd.command(_, modname)
   local pathname, rock_name, rock_version = loader.which(modname)
   if not pathname then
      return nil, "Module '" .. modname .. "' not found by luarocks.loader."
   end
   util.printout(pathname)
   util.printout("(provided by " .. tostring(rock_name) .. " " .. tostring(rock_version) .. ")")
   return true
end

return which_cmd