debug console inject cmd support args

This commit is contained in:
btt
2018-08-23 16:54:06 +08:00
committed by 云风
parent 7b3c1631d1
commit 18a36c171f
3 changed files with 7 additions and 6 deletions

View File

@@ -50,9 +50,10 @@ local function init(skynet, export)
skynet.exit()
end
function dbgcmd.RUN(source, filename)
function dbgcmd.RUN(source, filename, ...)
local inject = require "skynet.inject"
local ok, output = inject(skynet, source, filename , export.dispatch, skynet.register_protocol)
local args = table.pack(...)
local ok, output = inject(skynet, source, filename, args, export.dispatch, skynet.register_protocol)
collectgarbage "collect"
skynet.ret(skynet.pack(ok, table.concat(output, "\n")))
end

View File

@@ -18,7 +18,7 @@ local function getupvaluetable(u, func, unique)
end
end
return function(skynet, source, filename , ...)
return function(skynet, source, filename, args, ...)
if filename then
filename = "@" .. filename
else
@@ -56,7 +56,7 @@ return function(skynet, source, filename , ...)
if not func then
return false, { err }
end
local ok, err = skynet.pcall(func)
local ok, err = skynet.pcall(func, table.unpack(args, 1, args.n))
if not ok then
table.insert(output, err)
return false, output

View File

@@ -237,7 +237,7 @@ function COMMAND.exit(address)
skynet.send(adjust_address(address), "debug", "EXIT")
end
function COMMAND.inject(address, filename)
function COMMAND.inject(address, filename, ...)
address = adjust_address(address)
local f = io.open(filename, "rb")
if not f then
@@ -245,7 +245,7 @@ function COMMAND.inject(address, filename)
end
local source = f:read "*a"
f:close()
local ok, output = skynet.call(address, "debug", "RUN", source, filename)
local ok, output = skynet.call(address, "debug", "RUN", source, filename, ...)
if ok == false then
error(output)
end