local M = {} local function read_file(path) local fd = io.open(path, "r") if not fd then return nil end local content = fd:read("*a") fd:close() return content end local function write_file(path, content) local dir = path:match("(.*/)[^/]+$") if dir then vim.fn.mkdir(dir, "p") end local fd = io.open(path, "w") if not fd then error("Cannot write " .. path) end fd:write(content) fd:close() end local function extract_attributes(tag) local attrs = {} for k, v in tag:gmatch('(%w+)%s*=%s*"([^"]*)"') do attrs[k] = v end return attrs end local function parse_run_configuration(xml) -- find ... local cfg_tag, body = xml:match("]*)>(.-)") if not cfg_tag then -- sometimes configuration is self-closing: cfg_tag = xml:match("]+)/>") body = "" end if not cfg_tag then return nil end local cfg_attrs = extract_attributes(cfg_tag) local result = { _attrs = cfg_attrs, options = {} } -- options: