gemini-server/main.cpp

35 lines
1.0 KiB
C++
Raw Normal View History

2021-01-07 21:01:47 +01:00
#include <iostream>
#include <boost/program_options.hpp>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
#include "include/configuration.hpp"
2021-01-07 21:01:47 +01:00
namespace po = boost::program_options;
int main(int argc, char *argv[]) {
// Create logger
auto logger = spdlog::stdout_color_st("single_log");
spdlog::set_default_logger(logger);
po::options_description description{ "Allowed options" };
description.add_options()("help", "produce help message")("config", po::value<std::string>(), "path to the config file");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, description), vm);
po::notify(vm);
if (vm.count("help")) {
std::cout << description << '\n';
return EXIT_SUCCESS;
}
const gemini::Configuration configuration = [&]() -> gemini::Configuration {
if (vm.count("config")) {
spdlog::debug("config file was set to {}", vm["config"].as<std::string>());
return gemini::Configuration{ vm["config"].as<std::string>() };
}
return gemini::Configuration{};
}();
2021-01-07 21:01:47 +01:00
return EXIT_SUCCESS;
}