blob: a0effa3c881f4b9f21435abb039ae1c6f1c84203 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include "util.h"
#include <iostream>
#include <fmt/format.h>
void check_call(const std::vector<std::string>& cmd) {
std::string cmdstr;
bool first = true;
for (const auto& segment : cmd) {
if (first) {
first = false;
} else {
cmdstr += " ";
}
cmdstr += segment;
}
int code = system(cmdstr.c_str());
if (code != 0) {
std::cerr << cmdstr << " failed with return code " << code << std::endl;
std::exit(1);
}
}
std::string opt_param(const std::string& format, int defaultVal, int value) {
if (value != defaultVal) {
return fmt::format(format, value);
}
return "";
}
|