Commit 5bc184a5 authored by jan.koester's avatar jan.koester
Browse files

tetst

parent 3fdb2a13
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ else()
        netplus::netplus
        htmlpp::htmlpp
        confplus::confplus
        cmdplus::cmdplus
        dbpp::dbpp
        json-c::json-c
        tinyxml2::tinyxml2
+22 −13
Original line number Diff line number Diff line
@@ -30,9 +30,11 @@
#include <string>
#include <csignal>

#include <cmdplus/cmdplus.h>
#include <netplus/exception.h>
#include <httppp/httpd.h>
#include <httppp/exception.h>
#include <confplus/exception.h>

#include "plugin.h"
#include "webedit_config.h"
@@ -44,19 +46,23 @@ static void signalHandler(int sig) {
}

int main(int argc, char *argv[]) {
    std::string configPath = "/etc/blogi-webedit/config.yaml";

    // Parse arguments
    for (int i = 1; i < argc; ++i) {
        std::string arg = argv[i];
        if ((arg == "--config" || arg == "-c") && i + 1 < argc) {
            configPath = argv[++i];
        } else if (arg == "--help" || arg == "-h") {
            std::cout << "Usage: blogi-webedit [OPTIONS]\n"
                      << "  -c, --config <path>   Path to config.yaml\n"
                      << "  -h, --help            Show this help\n";
    cmdplus::CmdController cmdCtl(cmdplus::CmdController::getInstance());

    cmdCtl.registerCmd("help", 'h', false, "", "Show this help");
    cmdCtl.registerCmd("config", 'c', true, "", "Path to config file");
    cmdCtl.registerCmd("foreground", 'f', false, "", "Run in foreground");

    cmdCtl.parseCmd(argc, argv);

    if (cmdCtl.getCmdbyKey("help")->getFound()) {
        cmdCtl.printHelp();
        return 0;
    }

    std::string configPath = cmdCtl.getCmdbyKey("config")->getValue();

    if (configPath.empty()) {
        configPath = "yaml:/etc/blogi-editor/config.yaml";
    }

    signal(SIGPIPE, signalHandler);
@@ -103,6 +109,9 @@ int main(int argc, char *argv[]) {

        server.runEventloop();

    } catch (confplus::ConfException &e) {
        std::cerr << "Config error: " << e.what() << std::endl;
        return 1;
    } catch (netplus::NetException &e) {
        std::cerr << "Network error: " << e.what() << std::endl;
        return 1;