automatically search for config file in the assets dir

This commit is contained in:
loki
2020-01-29 14:31:02 -05:00
parent 11d25b0203
commit c0ff2c79e8
3 changed files with 12 additions and 9 deletions

View File

@@ -63,13 +63,16 @@ void on_signal(int sig, FN &&fn) {
}
int main(int argc, char *argv[]) {
const char *config_file = SUNSHINE_ASSETS_DIR "/sunshine.conf";
if(argc > 1) {
if(!std::filesystem::exists(argv[1])) {
std::cout << "Fatal Error: Couldn't find configuration file ["sv << argv[1] << ']' << std::endl;
return 7;
}
config_file = argv[1];
}
config::parse_file(argv[1]);
if(!std::filesystem::exists(config_file)) {
std::cout << "Warning: Couldn't find configuration file ["sv << config_file << ']' << std::endl;
}
else {
config::parse_file(config_file);
}
sink = boost::make_shared<text_sink>();