38 |
38 |
39 int main(int argc, char** argv) { |
39 int main(int argc, char** argv) { |
40 setlocale(LC_ALL, ""); |
40 setlocale(LC_ALL, ""); |
41 CLI::untieStdIO(); |
41 CLI::untieStdIO(); |
42 CLI cli(argc, argv); |
42 CLI cli(argc, argv); |
43 // TODO: options, CLI parsing, configurable attributes |
|
44 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
43 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
45 |
44 |
46 try { |
45 try { |
47 signal(SIGHUP, finish); |
46 signal(SIGHUP, finish); |
48 signal(SIGINT, finish); |
47 signal(SIGINT, finish); |
50 Configuration configuration = cliParser.parse(cli.arguments()); |
49 Configuration configuration = cliParser.parse(cli.arguments()); |
51 jackCommand.reset(new JackCommand(configuration)); |
50 jackCommand.reset(new JackCommand(configuration)); |
52 std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout)); |
51 std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout)); |
53 jackCommand->processJackStream(writer, std::bind(fflush, stdout)); // std::bind(fflush, XXX) Factory::create(XXX) must be the same stream XXX |
52 jackCommand->processJackStream(writer, std::bind(fflush, stdout)); // std::bind(fflush, XXX) Factory::create(XXX) must be the same stream XXX |
54 resultCode = CLI::EXIT_CODE_SUCCESS; |
53 resultCode = CLI::EXIT_CODE_SUCCESS; |
|
54 } catch (RelpipeCLIException e) { |
|
55 fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str()); |
|
56 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
|
57 resultCode = e.getExitCode(); |
55 } catch (JackException e) { |
58 } catch (JackException e) { |
56 fwprintf(stderr, L"Caught JACK exception: %ls\n", e.getMessge().c_str()); |
59 fwprintf(stderr, L"Caught JACK exception: %ls\n", e.getMessge().c_str()); |
57 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
60 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
58 resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
61 resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
59 } catch (RelpipeWriterException e) { |
62 } catch (RelpipeWriterException e) { |