feat: interactive mode

This commit is contained in:
Barrett Ruth 2025-10-05 15:36:28 -04:00
parent f00691ae40
commit 41a8d1a75b
6 changed files with 144 additions and 19 deletions

View file

@ -15,6 +15,7 @@ local actions = constants.ACTIONS
---@field contest? string
---@field platform? string
---@field problem_id? string
---@field interactor_cmd? string
--- Turn raw args into normalized structure to later dispatch
---@param args string[] The raw command-line mode args
@ -32,7 +33,7 @@ local function parse_command(args)
if first == 'cache' then
local subcommand = args[2]
if not subcommand then
return { type = 'error', message = 'cache command requires subcommand: clear' }
return { type = 'error', message = 'cache command requires subcommand' }
end
if vim.tbl_contains({ 'clear', 'read' }, subcommand) then
local platform = args[3]
@ -44,6 +45,13 @@ local function parse_command(args)
else
return { type = 'error', message = 'unknown cache subcommand: ' .. subcommand }
end
elseif first == 'interact' then
local inter = args[2]
if inter and inter ~= '' then
return { type = 'action', action = 'interact', interactor_cmd = inter }
else
return { type = 'action', action = 'interact' }
end
else
return { type = 'action', action = first }
end
@ -99,7 +107,7 @@ function M.handle_command(opts)
local ui = require('cp.ui.panel')
if cmd.action == 'interact' then
ui.toggle_interactive()
ui.toggle_interactive(cmd.interactor_cmd)
elseif cmd.action == 'run' then
ui.toggle_run_panel()
elseif cmd.action == 'debug' then