Add silent mode to ConfigurationManager, used by essimporter

openmw-35
scrawl 10 years ago
parent e7056b4e27
commit ef3ba12cb6

@ -45,7 +45,7 @@ int main(int argc, char** argv)
bpo::notify(variables); bpo::notify(variables);
Files::ConfigurationManager cfgManager; Files::ConfigurationManager cfgManager(true);
cfgManager.readConfiguration(variables, desc); cfgManager.readConfiguration(variables, desc);
std::string essFile = variables["mwsave"].as<std::string>(); std::string essFile = variables["mwsave"].as<std::string>();

@ -27,8 +27,9 @@ const char* const localToken = "?local?";
const char* const userDataToken = "?userdata?"; const char* const userDataToken = "?userdata?";
const char* const globalToken = "?global?"; const char* const globalToken = "?global?";
ConfigurationManager::ConfigurationManager() ConfigurationManager::ConfigurationManager(bool silent)
: mFixedPath(applicationName) : mFixedPath(applicationName)
, mSilent(silent)
{ {
setupTokensMapping(); setupTokensMapping();
@ -129,7 +130,8 @@ void ConfigurationManager::loadConfig(const boost::filesystem::path& path,
cfgFile /= std::string(openmwCfgFile); cfgFile /= std::string(openmwCfgFile);
if (boost::filesystem::is_regular_file(cfgFile)) if (boost::filesystem::is_regular_file(cfgFile))
{ {
std::cout << "Loading config file: " << cfgFile.string() << "... "; if (!mSilent)
std::cout << "Loading config file: " << cfgFile.string() << "... ";
boost::filesystem::ifstream configFileStream(cfgFile); boost::filesystem::ifstream configFileStream(cfgFile);
if (configFileStream.is_open()) if (configFileStream.is_open())
@ -137,11 +139,13 @@ void ConfigurationManager::loadConfig(const boost::filesystem::path& path,
boost::program_options::store(boost::program_options::parse_config_file( boost::program_options::store(boost::program_options::parse_config_file(
configFileStream, description, true), variables); configFileStream, description, true), variables);
std::cout << "done." << std::endl; if (!mSilent)
std::cout << "done." << std::endl;
} }
else else
{ {
std::cout << "failed." << std::endl; if (!mSilent)
std::cout << "failed." << std::endl;
} }
} }
} }

@ -25,7 +25,7 @@ namespace Files
*/ */
struct ConfigurationManager struct ConfigurationManager
{ {
ConfigurationManager(); ConfigurationManager(bool silent=false); /// @param silent Emit log messages to cout?
virtual ~ConfigurationManager(); virtual ~ConfigurationManager();
void readConfiguration(boost::program_options::variables_map& variables, void readConfiguration(boost::program_options::variables_map& variables,
@ -69,6 +69,8 @@ struct ConfigurationManager
boost::filesystem::path mLogPath; boost::filesystem::path mLogPath;
TokensMappingContainer mTokensMapping; TokensMappingContainer mTokensMapping;
bool mSilent;
}; };
} /* namespace Cfg */ } /* namespace Cfg */

Loading…
Cancel
Save