From 3129cd5005814ddd4fba736f127bf7f13809d4b7 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Tue, 16 May 2017 12:09:06 +0800 Subject: add -c cmdline option for task lua --- xmake/plugins/lua/xmake.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'xmake/plugins/lua') diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua index 1c6b2bf27..3e161cd4c 100644 --- a/xmake/plugins/lua/xmake.lua +++ b/xmake/plugins/lua/xmake.lua @@ -45,8 +45,17 @@ task("lua") return end + -- run command? + local cmd = option.get("command") + local name = nil + if cmd then + local tmpfile = os.tmpfile() .. ".lua" + io.writefile(tmpfile, "function main()\n" .. cmd .. "\nend") + name = tmpfile + end + -- get script name - local name = option.get("script") + name = name or option.get("script") if name then -- import and run script @@ -77,6 +86,7 @@ task("lua") { {'l', "list", "k", nil, "List all scripts." } , {nil, "root", "k", nil, "Allow to run script as root." } + , {'c', "command", "kv", nil, "Run command" } , {nil, "script", "v", nil, "Run the given lua script." } , {nil, "arguments", "vs", nil, "The script arguments." } } -- cgit v1.3.1