41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
#include <iostream>
|
|
#include <boost/program_options.hpp>
|
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
|
#include <spdlog/spdlog.h>
|
|
#include "include/configuration.hpp"
|
|
|
|
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);
|
|
|
|
// If the user si root, stop the program
|
|
if (getuid() == 0) {
|
|
spdlog::error("The user is root. Stopping the program.");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
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{};
|
|
}();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|