summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-23 17:16:57 +0800
committerruki <[email protected]>2022-07-23 17:16:57 +0800
commit712ee63202583f560e44f604335cf2419ce771c6 (patch)
tree5510ee40181a3a483a34d446fd099b3c9dfd88f3
parent75e5e111d3d3504d30f1b17ea51dab5417e44163 (diff)
run arbitrary command
-rw-r--r--xmake/plugins/watch/main.lua11
-rw-r--r--xmake/plugins/watch/xmake.lua5
2 files changed, 11 insertions, 5 deletions
diff --git a/xmake/plugins/watch/main.lua b/xmake/plugins/watch/main.lua
index 12afa47fd..9d3c8ed0f 100644
--- a/xmake/plugins/watch/main.lua
+++ b/xmake/plugins/watch/main.lua
@@ -58,12 +58,17 @@ function _run_command()
try
{
function ()
- local command = option.get("command")
+ local commands = option.get("commands")
local scriptfile = option.get("script")
- if command then
- for _, command in ipairs(command:split(";")) do
+ local arbitrary = option.get("arbitrary")
+ if commands then
+ for _, command in ipairs(commands:split(";")) do
os.exec(command)
end
+ elseif arbitrary then
+ local program = arbitrary[1]
+ local argv = #arbitrary > 1 and table.slice(arbitrary, 2) or {}
+ os.execv(program, argv)
elseif scriptfile and os.isfile(scriptfile) and path.extension(scriptfile) == ".lua" then
local script = import(path.basename(scriptfile),
{rootdir = path.directory(scriptfile), anonymous = true})
diff --git a/xmake/plugins/watch/xmake.lua b/xmake/plugins/watch/xmake.lua
index 8139bbd34..746500afd 100644
--- a/xmake/plugins/watch/xmake.lua
+++ b/xmake/plugins/watch/xmake.lua
@@ -26,7 +26,7 @@ task("watch")
, description = "Watch the project directories and run command."
, options =
{
- {'c', "command" , "kv" , nil , "Run the given command instead of the default build command.",
+ {'c', "commands" , "kv" , nil , "Run the given commands instead of the default build command.",
"e.g.",
" $ xmake watch -c 'xmake -rv'",
" $ xmake watch -c 'xmake -vD; xmake run hello'"},
@@ -39,7 +39,8 @@ task("watch")
" $ xmake watch -d 'src/*" .. path.envsep() .. "tests/**/subdir'"},
{'r', "run" , "k" , nil , "Build and run target."},
{'t', "target" , "kv" , nil , "Build the given target.",
- values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
+ values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end },
+ {'-', "arbitrary" , "vs" , nil , "Run an arbitrary command."}
}
}