diff --git a/backends/libcommuni/main.cpp b/backends/libcommuni/main.cpp index 9b717d4ca7ebb2ccea6ee3f165b06905d808d7bc..4509b9af50c331305afe5906692f594260293ff5 100644 --- a/backends/libcommuni/main.cpp +++ b/backends/libcommuni/main.cpp @@ -27,62 +27,24 @@ int main (int argc, char* argv[]) { std::string host; int port; - - boost::program_options::options_description desc("Usage: spectrum [OPTIONS] \nAllowed options"); - desc.add_options() - ("host,h", value(&host), "host") - ("port,p", value(&port), "port") - ; - try - { - boost::program_options::variables_map vm; - boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); - boost::program_options::notify(vm); - } - catch (std::runtime_error& e) - { - std::cout << desc << "\n"; - exit(1); - } - catch (...) - { - std::cout << desc << "\n"; - exit(1); - } - - - if (argc < 5) { - qDebug("Usage: %s ", argv[0]); + std::string error; + Config *cfg = Config::createFromArgs(argc, argv, error, host, port); + if (cfg == NULL) { + std::cerr << error; return 1; } -// QStringList channels; -// for (int i = 3; i < argc; ++i) -// { -// channels.append(argv[i]); -// } -// -// MyIrcSession session; -// session.setNick(argv[2]); -// session.setAutoJoinChannels(channels); -// session.connectToServer(argv[1], 6667); - - Config config; - if (!config.load(argv[5])) { - std::cerr << "Can't open " << argv[1] << " configuration file.\n"; - return 1; - } QCoreApplication app(argc, argv); - Logging::initBackendLogging(&config); + Logging::initBackendLogging(cfg); Swift::QtEventLoop eventLoop; - if (config.getUnregistered().find("service.irc_server") == config.getUnregistered().end()) { - np = new IRCNetworkPlugin(&config, &eventLoop, host, port); + if (!CONFIG_HAS_KEY(cfg, "service.irc_server")) { + np = new IRCNetworkPlugin(cfg, &eventLoop, host, port); } else { - np = new SingleIRCNetworkPlugin(&config, &eventLoop, host, port); + np = new SingleIRCNetworkPlugin(cfg, &eventLoop, host, port); } return app.exec();