Start with luadebug

This commit is contained in:
2025-10-23 23:13:48 +02:00
parent 8cde56a4e8
commit 1cd7b378b6
5 changed files with 94 additions and 24 deletions

46
runners/luadebug.lua Normal file
View File

@ -0,0 +1,46 @@
local core = require "core"
local process = require "process"
---@class LDB
local LDB = {
name = "luadebug"
}
---@param target table Target table
---@param name string Name of the target to run
---@return process|nil
function LDB:run(target, name)
end
-- Wait untill it ends, possibly with timeout
---@param proc process Process object
---@param time any Time field, process.WAIT_INFINITE
function LDB:wait(proc, time)
return proc:wait(time)
end
-- Read the stdout, returns nil if process has stopped
---@param proc process Process object
function LDB:read_stdout(proc)
return proc:read_stdout()
end
-- Read the stderr
---@param proc process Process object
function LDB:read_stderr(proc)
return proc:read_stderr()
end
-- Kill the process
---@param proc process Process object
function LDB:kill(proc)
proc:kill()
end
-- Terminate the process
---@param proc process Process object
function LDB:terminate(proc)
proc:terminate()
end
return LDB

View File

@ -7,14 +7,19 @@ local M = {
}
-- Run a shell command
---@param cmd table|string List of command pieces or in full
---@param opts table Options to run the command. Should contain env (table), cwd (string), stdout and stdin
---@param target table Target table
---@param name string Name of the target to run
---@return process|nil
function M:run(cmd, opts, name)
function M:run(target, name)
core.log("[jpdebug] Running shell command")
if cmd then
local proc = process.start(cmd, opts)
local opts = {
cwd = target.cwd or ".",
env = target.env or {},
stdout = process.REDIRECT_PIPE,
stderr = process.REDIRECT_PIPE
}
if target.cmd then
local proc = process.start(target.cmd, opts)
return proc
else
core.error("[jpdebug] command not specified for target %s", name)