cam: options: Indent multi-line help message correctly

Split multi-line help messages and indent all lines the same way.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart 2019-01-26 17:15:23 +02:00
parent 825bee2d11
commit aae0b7ffb1

View file

@ -153,7 +153,17 @@ void OptionsParser::usage()
}
std::cerr << std::setw(indent) << std::left << argument;
std::cerr << option.help << std::endl;
for (const char *help = option.help, *end = help; end; ) {
end = strchr(help, '\n');
if (end) {
std::cerr << std::string(help, end - help + 1);
std::cerr << std::setw(indent) << " ";
help = end + 1;
} else {
std::cerr << help << std::endl;
}
}
}
}