cam: options: Slit OptionsParser::usage() in two functions

To prepare for code reuse, split the printing of options out of
OptionsParser::usage() to a separate function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2021-07-06 06:56:19 +03:00
parent 7c205c79d9
commit a8f3a68ec9
2 changed files with 11 additions and 3 deletions

View file

@ -902,8 +902,6 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
*/
void OptionsParser::usage()
{
std::cerr << "Options:" << std::endl;
unsigned int indent = 0;
for (const Option &option : options_) {
@ -923,7 +921,15 @@ void OptionsParser::usage()
indent = (indent + 7) / 8 * 8;
for (const Option &option : options_) {
std::cerr << "Options:" << std::endl;
usageOptions(options_, indent);
}
void OptionsParser::usageOptions(const std::list<Option> &options,
unsigned int indent)
{
for (const Option &option : options) {
std::string argument;
if (option.hasShortOption())
argument = std::string(" -")

View file

@ -95,6 +95,8 @@ public:
void usage();
private:
void usageOptions(const std::list<Option> &options, unsigned int indent);
std::list<Option> options_;
std::map<unsigned int, Option *> optionsMap_;
};