return true, e
end
+--- call a tool with argv
+-- @param tool string: tool name as registered in the tools library
+-- @param argv table: a vector of (string) arguments
+-- @return bool
+-- @return string: the last line ouf captured output
+function call_tool_argv(tool, argv)
+ local cmd = tools.get_tool(tool)
+ if not cmd then
+ bomb("trying to call invalid tool: " .. tostring(tool))
+ end
+ local flags = tools.get_tool_flags(tool)
+ if not flags then
+ bomb("invalid tool flags for tool: " .. tostring(tool))
+ end
+
+ -- TODO: flags should be quoted as well, requires config changes
+ local call = string.format("%s %s", e2lib.shquote(cmd), flags)
+
+ for _,arg in ipairs(argv) do
+ assert(type(arg) == "string")
+ call = call .. " " .. e2lib.shquote(arg)
+ end
+
+ local rc, e = callcmd_log(call)
+ if rc ~= 0 then
+ return false, e
+ end
+ return true, e
+end
+
--- call git
-- @param gitdir string: GIT_DIR (optional, defaults to ".git")
-- @param subtool string: git tool name