Skip to content

Commit

Permalink
added "list_2_Tbl" to support table input for setenv modfunc
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcawood committed Oct 9, 2024
1 parent b6dd349 commit f0d27ce
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/modfuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,38 @@ function pushenv(...)
return
end

--------------------------------------------------------------------------
-- Convert all function arguments to table form
-- first_elem seperated from args for type test
function list_2_Tbl(first_elem, ...)
dbg.start{"list_2_Tbl(",l_concatTbl({first_elem, ...},", "),")"}

local t = nil
if ( type(first_elem) == "table" )then
t = first_elem
t.kind = "table"
else
t = pack(first_elem, ...)
t.kind = "list"
end
dbg.print{"OutputTable: ", l_concatTbl(t, ", "), "\n"}
dbg.fini("list_2_Tbl")
return t
end

--------------------------------------------------------------------------
-- Set the value of environment variable.
function setenv(...)
dbg.start{"setenv(",l_concatTbl({...},", "),")"}

if (not l_validateArgsWithValue("setenv",...)) then return end

--local mcp_old = mcp
local table = list_2_Tbl(...)

--mcp = mcp_old
--dbg.print{"Setting mcp to ", mcp:name(),"\n"}

mcp:setenv(...)
dbg.fini("setenv")
return
Expand Down

0 comments on commit f0d27ce

Please sign in to comment.