30 #include <relpipe/writer/TypeId.h> |
30 #include <relpipe/writer/TypeId.h> |
31 |
31 |
32 #include <relpipe/cli/CLI.h> |
32 #include <relpipe/cli/CLI.h> |
33 |
33 |
34 #include "XMLTableCommand.h" |
34 #include "XMLTableCommand.h" |
|
35 #include "CLIParser.h" |
|
36 #include "Configuration.h" |
35 |
37 |
36 using namespace relpipe::cli; |
38 using namespace relpipe::cli; |
37 using namespace relpipe::writer; |
39 using namespace relpipe::writer; |
38 using namespace relpipe::in::xmltable; |
40 using namespace relpipe::in::xmltable; |
39 |
41 |
43 CLI cli(argc, argv); |
45 CLI cli(argc, argv); |
44 |
46 |
45 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
47 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
46 |
48 |
47 try { |
49 try { |
|
50 CLIParser cliParser; |
|
51 Configuration configuration = cliParser.parse(cli.arguments()); |
48 XMLCommand command; |
52 XMLCommand command; |
49 command.process(cin, cout); |
53 command.process(cin, cout); |
50 resultCode = CLI::EXIT_CODE_SUCCESS; |
54 resultCode = CLI::EXIT_CODE_SUCCESS; |
51 } catch (RelpipeWriterException& e) { |
55 } catch (RelpipeWriterException& e) { |
52 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()); |
53 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()); |
54 resultCode = CLI::EXIT_CODE_DATA_ERROR; |
58 resultCode = CLI::EXIT_CODE_DATA_ERROR; |
|
59 } catch (RelpipeCLIException& e) { |
|
60 fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str()); |
|
61 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
|
62 resultCode = e.getExitCode(); |
55 } // TODO: catch xmlpp::exception |
63 } // TODO: catch xmlpp::exception |
56 |
64 |
57 return resultCode; |
65 return resultCode; |
58 } |
66 } |