I set flagfile like this:
DECLARE_string(flagfile);
int main(int argc, char** argv) {
FLAGS_flagfile = "./conf/default.conf"
ParseCommandLineFlags(&argc, &argv, true);
....
}
then change flagfile by command line
./main --flagfile=./conf/another.conf
but flagfile is still ./conf/default.conf
How to set flagfile's default value and also accept changes by command line?
You can simply check the parameters yourself before calling the
ParseCommandLineFlags
function.For example something like:
That way you will use the other configuration file. You can change the regex to match differently depending on what you need.