36#ifndef PROVSQL_TOOL_REGISTRY_H
37#define PROVSQL_TOOL_REGISTRY_H
58 const std::string &tpl,
const std::string &binary,
59 const std::string &in,
const std::string &out,
60 const std::vector<std::pair<std::string, std::string>> &extra = {})
62 auto sub = [](std::string &s,
const std::string &key,
63 const std::string &value) {
64 const std::string token =
"{" + key +
"}";
65 std::string::size_type pos = 0;
66 while ((pos = s.find(token, pos)) != std::string::npos) {
67 s.replace(pos, token.size(), value);
71 std::string cmd = tpl;
72 sub(cmd,
"binary", binary);
75 for (
const auto &kv : extra)
76 sub(cmd, kv.first, kv.second);
77 if (tpl.find(
"{binary}") == std::string::npos && !binary.empty())
78 return binary +
" " + cmd;
166 const std::string &in,
const std::string &out,
167 const std::string &binary_override,
168 const std::vector<std::pair<std::string, std::string>> &extra = {})
const;
186 bool provides(
const std::string &name,
const std::string &op)
const;
192 std::vector<const ToolRecord *>
byOperation(
const std::string &op)
const;
195 const std::vector<ToolRecord> &
records()
const {
203 bool remove(
const std::string &name);
206 bool setEnabled(
const std::string &name,
bool enabled);
ToolRegistry & tool_registry()
Shorthand for ToolRegistry::instance().
std::string expandCommandTemplate(const std::string &tpl, const std::string &binary, const std::string &in, const std::string &out, const std::vector< std::pair< std::string, std::string > > &extra={})
Expand a command template into a runnable shell command line.