format_option cleanup

master
Daniel Kolesa 2017-05-28 16:20:34 +02:00
parent e3acfa3005
commit 75c1c24a1c
1 changed files with 8 additions and 7 deletions

View File

@ -1676,12 +1676,9 @@ struct default_help_formatter {
template<typename OutputRange>
void format_option(OutputRange &out, arg_optional const &arg) {
std::string mt = arg.real_metavar();
bool first = true;
for (auto &s: arg.names()) {
if (!first) {
format(out, ", ");
}
format(out, s);
auto names = arg.names();
for (;;) {
format(out, names.front());
switch (arg.needs_value()) {
case arg_value::EXACTLY: {
for (auto nargs = arg.nargs(); nargs; --nargs) {
@ -1701,7 +1698,11 @@ struct default_help_formatter {
default:
break;
}
first = false;
names.pop_front();
if (names.empty()) {
break;
}
format(out, ", ");
}
}