Adam Hartshorne wrote:
Hi All,
I want to be able to do the following using the Boost::program_options library.
1) Parse a set of command line options in a standard way (I know how to achieve this).
2) Have an command line option which is "get other command line options from a config file defined as the argument to this option.
The example multiple_sources is very close to the sort of thing I want, however in that example the config file is hard coded. I want the user to interactively set the config file at runtime.
If I try simply putting the following lines in the set of if statements my program crashes (I know this is still hard coding the cfg file, but it was a first attempt before I made it more general),
if ((vm.count("input-file")) { ifstream ifs("multiple_sources.cfg"); store(parse_config_file(ifs, config_file_options), vm); notify(vm); }
This should work. What is the crash, specifically. Are you sure you're not calling 'notify' twice? Do you have a a try/catch block to catch any possible errors? - Volodya