summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamroot.jam1
-rw-r--r--src/Jamfile.jam1
-rw-r--r--src/webstat_logger_main.cpp27
3 files changed, 28 insertions, 1 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 1a9a214..5ec40fa 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -7,6 +7,7 @@ build-project src ;
build-project test ;
pkg-config.import glibmm : : <name>glibmm-2.68 ;
+lib boost_po : : <link>shared <name>boost_program_options ;
lib adhocutil : : <link>shared : : <include>/usr/include/adhocutil <library>glibmm ;
lib dbppcore : : <link>shared : : <include>/usr/include/dbpp <library>adhocutil ;
lib dbpp-postgresql : : <link>shared : : <include>/usr/include/dbpp-postgresql <library>dbppcore ;
diff --git a/src/Jamfile.jam b/src/Jamfile.jam
index a6abc93..38d8c37 100644
--- a/src/Jamfile.jam
+++ b/src/Jamfile.jam
@@ -10,4 +10,5 @@ lib webstat : ingestor.cpp logTypes.cpp sql.cpp :
exe webstat_logger : webstat_logger_main.cpp :
<library>webstat
<library>..//dbpp-postgresql
+ <library>..//boost_po
;
diff --git a/src/webstat_logger_main.cpp b/src/webstat_logger_main.cpp
index e4f871e..0db940a 100644
--- a/src/webstat_logger_main.cpp
+++ b/src/webstat_logger_main.cpp
@@ -1,5 +1,7 @@
#include "ingestor.hpp"
+#include <boost/program_options.hpp>
#include <format>
+#include <iostream>
#include <pq-connection.h>
#include <sys/utsname.h>
@@ -20,8 +22,31 @@ namespace {
}
int
-main(int, char **)
+main(int argc, char ** argv)
{
+ namespace po = boost::program_options;
+ po::options_description opts("WebStat logger");
+
+ // clang-format off
+ opts.add_options()
+ ("help,h", "Show this help message")
+ ("config,c", po::value<std::string>(), "Read config from this config file")
+ ;
+ // clang-format on
+ po::variables_map optVars;
+ po::store(po::command_line_parser(argc, argv).options(opts).run(), optVars);
+ if (const auto & rcPath = optVars.find("config"); rcPath != optVars.end()) {
+ po::store(po::parse_config_file(rcPath->second.as<std::string>().c_str(), opts), optVars);
+ }
+
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+ if (optVars.contains("help")) {
+ std::cout << opts << '\n';
+ return EXIT_FAILURE;
+ }
+ po::notify(optVars);
+
auto dbconn = std::make_shared<PQ::Connection>("dbname=webstat user=webstat");
WebStat::Ingestor {getHostname(false), dbconn}.ingestLog(stdin);
+ return EXIT_SUCCESS;
}