diff options
| author | ruki <[email protected]> | 2025-09-04 23:04:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-09-04 22:30:35 +0800 |
| commit | 9b446fb15e4c91cb6687cf904e4d39f3ce30637d (patch) | |
| tree | da572f2a689426fe137ec57278347c88925f8cb9 /xmake/modules/utils/run_script.lua | |
| parent | 4d11d90ba502bcd82a72c2ea66b1115897d81c52 (diff) | |
improve batchcmds:lua
Diffstat (limited to 'xmake/modules/utils/run_script.lua')
| -rw-r--r-- | xmake/modules/utils/run_script.lua | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/xmake/modules/utils/run_script.lua b/xmake/modules/utils/run_script.lua index 0394ccb6e..de625119f 100644 --- a/xmake/modules/utils/run_script.lua +++ b/xmake/modules/utils/run_script.lua @@ -19,8 +19,9 @@ -- -- imports -import("core.sandbox.module") +import("core.base.option") import("core.base.thread") +import("core.sandbox.module") -- print verbose log function _print_vlog(script_type, script_name, args, opt) @@ -142,11 +143,25 @@ function _get_args(opt) end function _run(script, opt) + opt = opt or {} + + if opt.quiet then + option.save() + option.set("quiet", true, {force = true}) + end + + local curdir = opt.curdir or os.workingdir() + local oldir = os.cd(curdir) if opt.command then _run_commanad(script, _get_args(opt), opt) else _run_script(script, _get_args(opt), opt) end + os.cd(oldir) + + if opt.quiet then + option.restore() + end end function _run_in_thread(script, opt) @@ -163,12 +178,11 @@ end -- - deserialize deserialize arguments starts with given prefix -- - arguments the script arguments -- - thread run script in a new native thread +-- - quiet enable quiet output -- - verbose enable verbose output -- - diagnosis enable diagnosis output function main(script, opt) opt = opt or {} - local curdir = opt.curdir or os.workingdir() - local oldir = os.cd(curdir) if opt.thread then local argv for _, arg in ipairs(opt.arguments) do @@ -183,6 +197,7 @@ function main(script, opt) command = opt.command, deserialize = opt.deserialize, arguments = argv, + quiet = opt.quiet, verbose = opt.verbose, diagnosis = opt.diagnosis } @@ -191,5 +206,4 @@ function main(script, opt) else _run(script, opt) end - os.cd(oldir) end |
