Lua:通过命令行参数选择脚本中的表是否可行?

我有一个 Lua 脚本,其中有许多类似下面这样的表

local a = {1,2,3}
local b = {1,2,3}
local c = {1,2,3}

等等,还有一个函数如下

test = {}
function test.set(args)
    for x, y in pairs(args) do
    ....
    end
end

test[arg[1]](arg[2])

现在我想通过命令行来选择其中一个表并将其用于该函数中。我尝试过

lua MyScript.lua set a

但我收到了以下错误

lua: MyScript.lua:1249: bad argument #1 to 'pairs' (table expected, got string)
stack traceback:
    [C]: in function 'pairs'
    MyScript.lua:1249: in field '?'
    MyScript.lua:1266: in main chunk
    [C]: in ?

这有点说得通,因为我传递了一个字符串。但我不知道如何选择我想要在函数中使用的表。有人能帮帮我吗?

点赞
用户6834680
用户6834680
本地所有的表格为: `all_your_tables = {a = {1,2,3}, b = {1,2,3}, c = {1,2,3}}`
...
执行测试: `test[arg[1]](all_your_tables[arg[2]])`
2019-05-23 07:58:52