diff options
| author | TitanSnow <[email protected]> | 2017-05-16 12:50:14 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-05-16 12:50:14 +0800 |
| commit | 37b4a7647163afdd392c7afcc61955244b6117cb (patch) | |
| tree | c81b8cb6f43dd5929e1edc0beb57ab075c965ebc /xmake/plugins/lua/xmake.lua | |
| parent | 3129cd5005814ddd4fba736f127bf7f13809d4b7 (diff) | |
| parent | a7c6ffab557760c2c2adf69e4f646c678f4e3034 (diff) | |
Merge branch 'dev' into command
Diffstat (limited to 'xmake/plugins/lua/xmake.lua')
| -rw-r--r-- | xmake/plugins/lua/xmake.lua | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua index 3e161cd4c..0b867d966 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")) @@ -60,9 +60,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 @@ -84,11 +93,17 @@ task("lua") -- options , options = { - {'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." } + + {'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 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." } } } |
