boost :: program_options:如何添加程序描述文本

时间:2011-08-05 09:58:05

标签: c++ boost-program-options

我希望在打印options_description时,在描述允许的选项之前打印文本。类似的东西:

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.

目前我手动添加:

if (vm.count("help")) {
    cout << "options_description\n\n" << my_options_description << endl;
    return 1;
}

是否可以将其直接存储在options_description对象中?

1 个答案:

答案 0 :(得分:6)

options_description类用于描述选项,而不是程序。 Program_options库并非真正用于通用文档。

我想你可以滥用标签:

po::options_description options(
  "This program counts from 1 to 10.\n\nGeneric options");