diff -r 0b38339b871b -r 19580b27ade2 src/relpipe-tr-sql.cpp --- a/src/relpipe-tr-sql.cpp Tue Oct 22 16:04:56 2019 +0200 +++ b/src/relpipe-tr-sql.cpp Tue Oct 22 16:05:36 2019 +0200 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -50,11 +51,20 @@ try { CLIParser cliParser; Configuration configuration = cliParser.parse(cli.arguments()); - std::shared_ptr reader(reader::Factory::create(std::cin)); - std::shared_ptr writer(writer::Factory::create(std::cout)); - SqlHandler handler(writer.get(), configuration); - reader->addHandler(&handler); - reader->process(); + + if (std::regex_match(cli.programName(), std::wregex(L"^(.*/)?relpipe-in-sql$"))) { + // relpipe-in-sql: + std::shared_ptr writer(writer::Factory::create(std::cout)); + SqlHandler handler(writer.get(), configuration); + handler.endOfPipe(); + } else { + // relpipe-tr-sql: + std::shared_ptr reader(reader::Factory::create(std::cin)); + std::shared_ptr writer(writer::Factory::create(std::cout)); + SqlHandler handler(writer.get(), configuration); + reader->addHandler(&handler); + reader->process(); + } resultCode = CLI::EXIT_CODE_SUCCESS;