ドキュメントでは、[オプショングループ]および[非表示オプション]の見出しの下でオプションを分離する方法について説明しています。options_description
複数のオブジェクトを定義しall
てから、コマンドラインを解析するためのグループを使用する方法を示しますが、visible
ドキュメントを表示するためのグループを使用します。
// Declare an options description instance which will include
// all the options
options_description all("Allowed options");
all.add(general).add(gui).add(backend);
// Declare an options description instance which will be shown
// to the user
options_description visible("Allowed options");
visible.add(general).add(gui);
variables_map vm;
store(parse_command_line(ac, av, all), vm);
if (vm.count("help"))
{
cout << visible;
return 0;
}
Although the Program_options library lets you customize some of the syntax (see Non-conventional Syntax and Custom Validators), it doesn't offer a way of defining a custom grammar. If you want to define the grammar of the command line, use a different tool.