50 try { |
51 try { |
51 CLIParser cliParser; |
52 CLIParser cliParser; |
52 Configuration configuration = cliParser.parse(cli.arguments()); |
53 Configuration configuration = cliParser.parse(cli.arguments()); |
53 std::shared_ptr<reader::RelationalReader> reader(reader::Factory::create(std::cin)); |
54 std::shared_ptr<reader::RelationalReader> reader(reader::Factory::create(std::cin)); |
54 std::shared_ptr<writer::RelationalWriter> writer(writer::Factory::create(std::cout)); |
55 std::shared_ptr<writer::RelationalWriter> writer(writer::Factory::create(std::cout)); |
55 AwkHandler handler(writer.get(), configuration); |
56 AwkHandler handler(writer.get(), std::bind(fflush, stdout), configuration); // std::bind(fflush, XXX) writer::Factory::create(XXX) must be the same stream XXX |
56 reader->addHandler(&handler); |
57 reader->addHandler(&handler); |
57 reader->process(); |
58 reader->process(); |
58 |
59 |
59 resultCode = CLI::EXIT_CODE_SUCCESS; |
60 resultCode = CLI::EXIT_CODE_SUCCESS; |
60 |
61 |
61 } catch (RelpipeCLIException& e) { |
62 } catch (RelpipeCLIException& e) { |
62 fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str()); |
63 fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str()); |
63 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
64 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |