I have trouble with boost::program_options. I have a piece of software composed of several subcomponents, each one of which can declare some options to be passed on the command line. I would like to stick to the following flow:
- Configure boost::program_options with some options
- Match options
- Use matched options to initialize subcomponents
- Subcomponents constructors declare more options
- Match options again to configure components
So, at a certain instant of execution (2), I have only declared a number of options, but the program is actually called with the whole set of them (including the ones that will be declared in 3), causing a number of unrecognised option '...' errors. I can catch those, but the parsing will stop anyway. I have tried handling that with multiple options_description groups, I have also looked into command line styles (style_t) to see whether one of them allowed to ignore unmatched arguments. Do you have some more ideas?
Thanks
Problem solved, sorry to bug you, but this could come handy to someone. Instead of using
parse_command_linecall
command_line_parser‘srunmethod explicitly after callingallow_unregistered