summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-06-03 00:19:50 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-06-03 00:19:50 +0100
commit88708a8aa6a33f265ff990102b44a9a51e3bf4bb (patch)
tree8e59a73be6366e3237c473834852a276f07a9963 /main
parentDetermine parameter mode at point of call by DB type property (diff)
downloadmygrate-88708a8aa6a33f265ff990102b44a9a51e3bf4bb.tar.bz2
mygrate-88708a8aa6a33f265ff990102b44a9a51e3bf4bb.tar.xz
mygrate-88708a8aa6a33f265ff990102b44a9a51e3bf4bb.zip
Get upstream from DB
Adds options from command line and a few supporting tweaks
Diffstat (limited to 'main')
-rw-r--r--main/Jamfile.jam2
-rw-r--r--main/main.cpp40
2 files changed, 35 insertions, 7 deletions
diff --git a/main/Jamfile.jam b/main/Jamfile.jam
index d03d005..7adaddb 100644
--- a/main/Jamfile.jam
+++ b/main/Jamfile.jam
@@ -1,2 +1,2 @@
-exe mygrate : main.cpp : <library>../lib//mygrate ;
+exe mygrate : main.cpp : <library>../lib//mygrate <library>..//po ;
#run main.cpp : : : <library>../lib//mygrate ;
diff --git a/main/main.cpp b/main/main.cpp
index bdcda75..815ca67 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1,10 +1,38 @@
-#include <input/replStream.h>
-#include <output/dumpToConsole.h>
+#include <boost/lexical_cast/bad_lexical_cast.hpp>
+#include <boost/program_options.hpp>
+#include <cstdint>
+#include <cstdlib>
+#include <eventSourceBase.h>
+#include <iostream>
+#include <memory>
+#include <output/pq/updateDatabase.h>
+#include <string>
+
+namespace po = boost::program_options;
int
-main(int, char **)
+main(int argc, char ** argv)
{
- MyGrate::Input::ReplicationStream rs {"192.168.1.38", "repl", "r3pl", 3306};
- MyGrate::Output::DumpToConsole dtc;
- rs.readEvents(dtc);
+ std::string pgconn;
+ uint64_t sourceid {};
+ bool help {};
+ po::options_description opts("MyGrate");
+ opts.add_options()("postgresql,p", po::value(&pgconn)->required(), "Target PostgreSQL connection string")(
+ "sourceid,s", po::value(&sourceid)->default_value(1), "Source identifier")("help,h",
+ po::value(&help)->zero_tokens(), "Help");
+
+ po::variables_map vm;
+ po::store(po::command_line_parser(argc, argv).options(opts).run(), vm);
+
+ if (vm.count("help")) {
+ std::cout << opts;
+ return EXIT_SUCCESS;
+ }
+ po::notify(vm);
+
+ MyGrate::Output::Pq::UpdateDatabase ud {pgconn.c_str(), sourceid};
+ auto src {ud.getSource()};
+ src->readEvents(ud);
+
+ return EXIT_SUCCESS;
}