When you use Boost library program_options
it is very easy to print help for your program:
boost::program_options::variables_map options;
boost::program_options::options_description optionsDesc;
boost::program_options::positional_options_description positionalOptionsDesc;
//...
if(options.count("help"))
{
cerr << optionsDesc << endl;
}
But how do you add the options from positional_options_description
to the help message? In the tutorial I can see the output of such set-up, at the end of the section:
http://www.boost.org/doc/libs/1_52_0/doc/html/program_options/tutorial.html#id2607297
The option input-file
is printed in help and it is positional. But I can't see the code.
Is there an build-in way to print it, like with options_description
or you have to do it manually? Apparently the <<
does not work for positional_options_description
, the compilation error is:
error: cannot bind ‘std::ostream {aka std::basic_ostream<char>}’ lvalue to ‘std::basic_ostream<char>&&’
options_description
if I add them topositional_options_description
, but you have to add to both. – Lemons