{lua,tup}-ext: add trim

This commit is contained in:
Christopher Monsanto 2020-05-02 21:40:17 -04:00
parent 7c503abb98
commit 58eb3de07a
3 changed files with 15 additions and 5 deletions

View File

@ -43,7 +43,8 @@ tup.rule(
makecmd{
display="pokemonicons-pokeball-sheet",
[[
convert -background transparent -gravity center -extent 40x30 %f +append %o]],
convert -background transparent -gravity center -extent 40x30 %f +append %o
]],
compresspng{config="SPRITESHEET"}
},
{"build/ps/pokemonicons-pokeball-sheet.png"}

View File

@ -67,3 +67,7 @@ function mergededup(table1, table2, f)
end
return result
end
function trim(s)
return s:gsub("^%s*(.-)%s*$", "%1")
end

View File

@ -46,10 +46,15 @@ end
function makecmd(cmds)
local cmd = ""
if cmds.display then
cmd = rep{"^ {display}^ ", display=cmds.display}
cmds.display = nil
for newcmd in iter(flatten(cmds)) do
newcmd = trim(newcmd)
if cmd ~= "" then
cmd = cmd .. " && "
end
cmd = cmd .. newcmd
end
if cmds.display then
cmd = rep{"^ {display}^ {cmd}", display=cmds.display, cmd=cmd}
end
cmd = cmd .. table.concat(flatten(cmds), " && ")
return cmd
end