| 63 | } |
| 64 | |
| 65 | int main(int argc, char* argv[]) { |
| 66 | static struct option longOptions[] = {{"help", no_argument, nullptr, 'h'}, |
| 67 | {"withIndex", no_argument, nullptr, 'i'}, |
| 68 | {nullptr, 0, nullptr, 0}}; |
| 69 | const char* filename = nullptr; |
| 70 | bool withIndex = false; |
| 71 | bool helpFlag = false; |
| 72 | int opt; |
| 73 | do { |
| 74 | opt = getopt_long(argc, argv, "hi", longOptions, nullptr); |
| 75 | switch (opt) { |
| 76 | case '?': |
| 77 | case 'h': |
| 78 | helpFlag = true; |
| 79 | opt = -1; |
| 80 | break; |
| 81 | case 'i': |
| 82 | withIndex = true; |
| 83 | break; |
| 84 | } |
| 85 | } while (opt != -1); |
| 86 | argc -= optind; |
| 87 | argv += optind; |
| 88 | |
| 89 | if (argc < 1 || helpFlag) { |
| 90 | std::cerr << "Usage: orc-statistics [-h] [--help] [-i] [--withIndex]" |
| 91 | << " <filenames>\n"; |
| 92 | exit(1); |
| 93 | } |
| 94 | |
| 95 | for (int i = 0; i < argc; ++i) { |
| 96 | filename = argv[i]; |
| 97 | try { |
| 98 | printStatistics(filename, withIndex); |
| 99 | } catch (std::exception& ex) { |
| 100 | std::cerr << "Caught exception: " << ex.what() << "\n"; |
| 101 | return 1; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | return 0; |
| 106 | } |
nothing calls this directly
no test coverage detected