Command-line arguments
are a common way to parameterize execution of programs.
For example, |
|
Function to make a string representation of a table https://stackoverflow.com/a/27028488/429544 |
local function dump(o) if type(o) == 'table' then local s = '{ ' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump(v) .. ',' end return s .. '} ' else return tostring(o) end end |
local args = {...} |
|
print(dump(args)) |
$ lua command-line-arguments.lua a b c d { [1] = a,[2] = b,[3] = c,[4] = d,} |
Next example: Environment Variables.