Imagine I have a program that takes the following command-line option:
$ prog1 --foo 1
I also have a configuration file that is in this hierarchical format, with the foo
parameter within the prog1
scope:
[prog1]
foo = 42
My understanding of Boost::program_options is that the command-line option is defined similar to:
description.add_options()
("foo", "Set foo value");
However I want the value in the config file to be a default value (as an outcome of calling store()
twice, first with the command-line description, then the config file description), able to be overriden by the command-line option, but I believe the config file option has to be declared as:
description.add_options()
("prog1.foo", "Set foo value");
Note the use of prog1.foo
here, especially the prog1.
prefix.
So my question is, if you use hierarchical config-file options, how do you associate these with command line options? I.e. how do I make --foo
and prog1.foo
represent the same configuration value in the Storage object?