|
|
@ -136,6 +136,7 @@ struct Command {
|
|
|
|
int depth = 0;
|
|
|
|
int depth = 0;
|
|
|
|
std::string command;
|
|
|
|
std::string command;
|
|
|
|
bool first_arg = true;
|
|
|
|
bool first_arg = true;
|
|
|
|
|
|
|
|
bool had_newline = false;
|
|
|
|
bool generated = false;
|
|
|
|
bool generated = false;
|
|
|
|
|
|
|
|
|
|
|
|
Command(std::stringstream &ss, int depth, const std::string &command) : ss(ss), depth(depth), command(command) {}
|
|
|
|
Command(std::stringstream &ss, int depth, const std::string &command) : ss(ss), depth(depth), command(command) {}
|
|
|
@ -181,10 +182,11 @@ struct Command {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ss << '\n';
|
|
|
|
|
|
|
|
for (const auto &value : vec) {
|
|
|
|
for (const auto &value : vec) {
|
|
|
|
ss << indent(depth + 1) << quote(value) << '\n';
|
|
|
|
ss << '\n' << indent(depth + 1) << quote(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
had_newline = true;
|
|
|
|
|
|
|
|
first_arg = false;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -194,10 +196,12 @@ struct Command {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ss << '\n';
|
|
|
|
|
|
|
|
for (const auto &itr : map) {
|
|
|
|
for (const auto &itr : map) {
|
|
|
|
ss << indent(depth + 1) << itr.first << ' ' << quote(itr.second) << '\n';
|
|
|
|
ss << '\n' << indent(depth + 1) << itr.first;
|
|
|
|
|
|
|
|
ss << '\n' << indent(depth + 2) << quote(itr.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
had_newline = true;
|
|
|
|
|
|
|
|
first_arg = false;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -209,7 +213,7 @@ struct Command {
|
|
|
|
if (first_arg) {
|
|
|
|
if (first_arg) {
|
|
|
|
first_arg = false;
|
|
|
|
first_arg = false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ss << ' ';
|
|
|
|
ss << (had_newline ? '\n' : ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ss << quote(value);
|
|
|
|
ss << quote(value);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -221,11 +225,12 @@ struct Command {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ss << '\n';
|
|
|
|
ss << '\n' << indent(depth + 1) << kv.first;
|
|
|
|
ss << indent(depth + 1) << kv.first << '\n';
|
|
|
|
|
|
|
|
for (const auto &s : kv.second) {
|
|
|
|
for (const auto &s : kv.second) {
|
|
|
|
ss << indent(depth + 2) << quote(s) << '\n';
|
|
|
|
ss << '\n' << indent(depth + 2) << quote(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
had_newline = true;
|
|
|
|
|
|
|
|
first_arg = false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -236,7 +241,10 @@ struct Command {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ss << indent(depth + 1) << kv.first << ' ' << quote(kv.second) << '\n';
|
|
|
|
ss << '\n' << indent(depth + 1) << kv.first;
|
|
|
|
|
|
|
|
ss << '\n' << indent(depth + 2) << quote(kv.second);
|
|
|
|
|
|
|
|
had_newline = true;
|
|
|
|
|
|
|
|
first_arg = false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -246,7 +254,7 @@ struct Command {
|
|
|
|
if (first_arg) {
|
|
|
|
if (first_arg) {
|
|
|
|
first_arg = false;
|
|
|
|
first_arg = false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ss << ' ';
|
|
|
|
ss << (had_newline ? '\n' : ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::stringstream tmp;
|
|
|
|
std::stringstream tmp;
|
|
|
|
tmp << value;
|
|
|
|
tmp << value;
|
|
|
@ -259,6 +267,8 @@ struct Command {
|
|
|
|
generated = true;
|
|
|
|
generated = true;
|
|
|
|
ss << indent(depth) << command << '(';
|
|
|
|
ss << indent(depth) << command << '(';
|
|
|
|
std::initializer_list<bool>{print_arg(values)...};
|
|
|
|
std::initializer_list<bool>{print_arg(values)...};
|
|
|
|
|
|
|
|
if (had_newline)
|
|
|
|
|
|
|
|
ss << '\n';
|
|
|
|
ss << ")\n";
|
|
|
|
ss << ")\n";
|
|
|
|
return CommandEndl(ss);
|
|
|
|
return CommandEndl(ss);
|
|
|
|
}
|
|
|
|
}
|
|
|
|