Last active
June 19, 2023 12:23
-
-
Save aurismat/335a72fbc2d4211aefc6bb7a404b66e5 to your computer and use it in GitHub Desktop.
luamod - list your lua module contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.