Skip to content

Instantly share code, notes, and snippets.

@aurismat
Last active June 19, 2023 12:23
Show Gist options
  • Save aurismat/335a72fbc2d4211aefc6bb7a404b66e5 to your computer and use it in GitHub Desktop.
Save aurismat/335a72fbc2d4211aefc6bb7a404b66e5 to your computer and use it in GitHub Desktop.
luamod - list your lua module contents
#!/usr/bin/lua
if #arg ~= 1 then
io.stderr:write("usage: test_lib <lua module>\n")
os.exit(1)
end
local req
if pcall(require, arg[1]) then
req = require(arg[1])
else
io.stderr:write("No such require found\n")
os.exit(1)
end
if not req then os.exit(1) end
for k, v in pairs(req) do
print(k, v)
end
@aurismat
Copy link
Author

Personally I put this script as an executable in my /usr/local/bin/ directory. Made to work for Lua 5.1, though I see no reason for it to not work with newer versions.
Usage: luamod <lua_module>, spits out all the lua modules in a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment