summaryrefslogtreecommitdiff
path: root/xmake/plugins/lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-16 10:31:40 +0800
committerruki <[email protected]>2017-05-16 10:32:16 +0800
commit76845e083b940445042896a87ebb482edcac8a36 (patch)
tree9b966443c8ca343cba52f58a61eb14c3d12f488b /xmake/plugins/lua
parent79634bd7f65737d619f87f6b38710195429843d0 (diff)
improve import interfaces and add user externsion modules
Diffstat (limited to 'xmake/plugins/lua')
-rw-r--r--xmake/plugins/lua/xmake.lua28
1 files changed, 21 insertions, 7 deletions
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua
index 1c6b2bf27..ba872f9cf 100644
--- a/xmake/plugins/lua/xmake.lua
+++ b/xmake/plugins/lua/xmake.lua
@@ -35,7 +35,7 @@ task("lua")
import("core.base.option")
import("core.sandbox.sandbox")
- -- list all scripts?
+ -- list all lua scripts?
if option.get("list") then
print("scripts:")
local files = os.match(path.join(os.scriptdir(), "scripts/*.lua"))
@@ -51,9 +51,18 @@ task("lua")
-- import and run script
if os.isfile(name) then
- import(path.basename(name), {rootdir = path.directory(name)}).main(unpack(option.get("arguments") or {}))
+
+ -- run the given lua script file (xmake lua /tmp/script.lua)
+ import(path.basename(name), {rootdir = path.directory(name)})(unpack(option.get("arguments") or {}))
+
+ elseif os.isfile(path.join(os.scriptdir(), "scripts", name .. ".lua")) then
+
+ -- run builtin lua script (xmake lua echo "hello xmake")
+ import("scripts." .. name)(unpack(option.get("arguments") or {}))
else
- import("scripts." .. name).main(unpack(option.get("arguments") or {}))
+
+ -- run modules (xmake lua core.xxx.xxx)
+ import(name)(unpack(option.get("arguments") or {}))
end
else
-- enter interactive mode
@@ -75,10 +84,15 @@ task("lua")
-- options
, options =
{
- {'l', "list", "k", nil, "List all scripts." }
- , {nil, "root", "k", nil, "Allow to run script as root." }
- , {nil, "script", "v", nil, "Run the given lua script." }
- , {nil, "arguments", "vs", nil, "The script arguments." }
+ {'l', "list", "k", nil, "List all scripts." }
+ , {nil, "root", "k", nil, "Allow to run script as root." }
+ , {nil, "script", "v", nil, "Run the given lua script name, file or module and enter interactive mode if no given script.",
+ ".e.g",
+ " - xmake lua (enter interactive mode)",
+ " - xmake lua /tmp/script.lua",
+ " - xmake lua echo 'hello xmake'",
+ " - xmake lua core.xxx.xxx" }
+ , {nil, "arguments", "vs", nil, "The script arguments." }
}
}