boost::program_options : how to add a program description text
I would like that a text is printed before the description of the allowed options when I print my options_description. Something like :
This program counts from 1 to 10. <--- this is what is missing
Generic options:
-h [ --help ] Produce help message.
-v [ --version ] Show program name/version banner and exit.
Currently I add it by hand :
if (vm.count("help")) {
cout << "options_description\n\n" << my_options_description << endl;
return 1;
}
Is i开发者_StackOverflow社区t possible to store this directly in the options_description object ?
The options_description
class is for describing the options, not the program. The Program_options library isn't really intended for general-purpose documentation.
I suppose you could abuse the label:
po::options_description options(
"This program counts from 1 to 10.\n\nGeneric options");
精彩评论