mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Properly merge in the default settings.
This commit is contained in:
14
lib/flags.cc
14
lib/flags.cc
@@ -183,19 +183,21 @@ void FlagGroup::parseFlagsWithConfigFiles(int argc, const char* argv[],
|
||||
parseFlags(argc, argv,
|
||||
[&](const auto& filename) {
|
||||
const auto& it = configFiles.find(filename);
|
||||
std::string data;
|
||||
if (it != configFiles.end())
|
||||
{
|
||||
if (!config.ParseFromString(it->second))
|
||||
Error() << "couldn't load config proto";
|
||||
}
|
||||
data = it->second;
|
||||
else
|
||||
{
|
||||
std::ifstream f(filename, std::ios::out);
|
||||
if (f.fail())
|
||||
Error() << fmt::format("Cannot open '{}': {}", filename, strerror(errno));
|
||||
if (!config.ParseFromIstream(&f))
|
||||
Error() << "couldn't load config proto";
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << f.rdbuf();
|
||||
data = ss.str();
|
||||
}
|
||||
if (!config.MergeFromString(data))
|
||||
Error() << "couldn't load config proto";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user