summaryrefslogtreecommitdiff
path: root/main/main.cpp
blob: 1df8f29eae4777f0f65e965722622413be086abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#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 argc, char ** argv)
{
	std::string pgconn;
	uint64_t sourceid {};
	bool help {};
	po::options_description opts("MyGrate");
	// clang-format off
	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");
	// clang-format on

	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;
}