diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/Jamfile.jam | 2 | ||||
-rw-r--r-- | main/main.cpp | 40 |
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; } |