diff -r 86ceb97db7de -r 24c05e69d68f src/relpipe-tr-sql.cpp --- a/src/relpipe-tr-sql.cpp Sat May 23 23:58:50 2020 +0200 +++ b/src/relpipe-tr-sql.cpp Mon May 25 19:36:06 2020 +0200 @@ -36,6 +36,7 @@ #include "SqlHandler.h" #include "CLIParser.h" #include "Configuration.h" +#include "DriverManager.h" using namespace relpipe::cli; using namespace relpipe::reader; @@ -52,19 +53,23 @@ CLIParser cliParser; Configuration configuration = cliParser.parse(cli.arguments()); - if (std::regex_match(cli.programName(), std::wregex(L"^(.*/)?relpipe-in-sql$"))) { + std::shared_ptr driverManager = std::make_shared(); + std::shared_ptr writer(writer::Factory::create(std::cout)); + + if (configuration.listDataSources) { + // --list-data-sources: + SqlHandler::listDataSources(writer.get(), driverManager.get()); + } else if (std::regex_match(cli.programName(), std::wregex(L"^(.*/)?relpipe-in-sql$"))) { // relpipe-in-sql: if (cli.arguments().size() == 0) configuration.copyRelations.push_back({L".*", L"", false}); - std::shared_ptr writer(writer::Factory::create(std::cout)); configuration.sqlBeforeRelational = isatty(fileno(stdin)) ? nullptr : &std::wcin; configuration.sqlAfterRelational = nullptr; - SqlHandler handler(writer.get(), configuration); + SqlHandler handler(writer.get(), driverManager.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); + SqlHandler handler(writer.get(), driverManager.get(), configuration); reader->addHandler(&handler); reader->process(); }