--- a/relpipe-in-cli.cpp Fri Jul 27 00:07:16 2018 +0200
+++ b/relpipe-in-cli.cpp Sat Jul 28 08:13:35 2018 +0200
@@ -4,10 +4,56 @@
#include <tuple>
#include <RelationalWriter.h>
+#include <RelpipeWriterException.h>
#include <Factory.h>
#include <TypeId.h>
+#include "CLI.h"
+
+int demo();
+
int main(int argc, char** argv) {
+ using namespace relpipe::cli;
+ using namespace relpipe::writer;
+
+ setlocale(LC_ALL, "");
+ CLI cli(argc, argv);
+
+ int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR;
+
+ try {
+ if (cli.arguments().size() > 0) {
+
+ const wstring action = cli.arguments()[0];
+ vector<wstring> arguments(cli.arguments().size() - 1);
+ for (int i = 1; i < cli.arguments().size(); i++) {
+ arguments[i - 1] = cli.arguments()[i];
+ }
+
+ if (action == L"demo") {
+ resultCode = demo();
+ } else {
+ fwprintf(stderr, L"Unknown command: %ls\n", action.c_str());
+ resultCode = CLI::EXIT_CODE_UNKNOWN_COMMAND;
+ }
+
+
+ } else {
+ fwprintf(stderr, L"Missing command…\n");
+ resultCode = CLI::EXIT_CODE_BAD_SYNTAX;
+ }
+ } catch (RelpipeWriterException e) {
+ fwprintf(stderr, L"Caught exception: %ls\n", e.getMessge().c_str());
+ fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount());
+ resultCode = CLI::EXIT_CODE_DATA_ERROR;
+ }
+
+
+ return resultCode;
+
+}
+
+int demo() {
using namespace relpipe::writer;
std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout));