lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

When creating a module sometimes is also useful to run it from the command line as a standalone application.
How to discover the invoke method?
Here's how I'm doing now:

-- checks if the module is being 'required' or executed

local STANDALONE = (debug.getinfo(1).short_src == (arg and arg[0]))
module ((...) or 'default_name')
...
if STANDALONE then
    whatever()
end