28 |
28 |
29 #include <relpipe/cli/CLI.h> |
29 #include <relpipe/cli/CLI.h> |
30 #include <relpipe/cli/RelpipeCLIException.h> |
30 #include <relpipe/cli/RelpipeCLIException.h> |
31 |
31 |
32 #include "FilesystemCommand.h" |
32 #include "FilesystemCommand.h" |
|
33 #include "ParallelFilesystemCommand.h" |
33 #include "CLIParser.h" |
34 #include "CLIParser.h" |
34 |
35 |
35 using namespace relpipe::cli; |
36 using namespace relpipe::cli; |
36 using namespace relpipe::writer; |
37 using namespace relpipe::writer; |
37 using namespace relpipe::in::filesystem; |
38 using namespace relpipe::in::filesystem; |
44 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
45 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
45 |
46 |
46 try { |
47 try { |
47 CLIParser cliParser; |
48 CLIParser cliParser; |
48 Configuration configuration = cliParser.parse(cli.arguments()); |
49 Configuration configuration = cliParser.parse(cli.arguments()); |
49 FilesystemCommand command; |
50 std::unique_ptr<FilesystemCommandBase> command; |
50 command.process(cin, cout, configuration); |
51 if (configuration.parallelism == 1) command = std::make_unique<FilesystemCommand>(); |
|
52 else command = std::make_unique<ParallelFilesystemCommand>(); |
|
53 command->process(cin, cout, configuration); |
51 resultCode = CLI::EXIT_CODE_SUCCESS; |
54 resultCode = CLI::EXIT_CODE_SUCCESS; |
52 } catch (RelpipeWriterException e) { |
55 } catch (RelpipeWriterException e) { |
53 fwprintf(stderr, L"Caught Writer exception: %ls\n", e.getMessge().c_str()); |
56 fwprintf(stderr, L"Caught Writer exception: %ls\n", e.getMessge().c_str()); |
54 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
57 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
55 resultCode = CLI::EXIT_CODE_DATA_ERROR; |
58 resultCode = CLI::EXIT_CODE_DATA_ERROR; |