| 120 | } |
| 121 | |
| 122 | int main(int argc, char *argv[]) { |
| 123 | std::ostream *stream = &std::cout; |
| 124 | Options opt; |
| 125 | std::string type; |
| 126 | { |
| 127 | namespace po = boost::program_options; |
| 128 | // clang-format off |
| 129 | po::options_description desc("Options"); |
| 130 | desc.add_options() |
| 131 | ("help,h", "produce help message") |
| 132 | ("output,O", po::value<std::string>(), "output file (defaults to standard out)") |
| 133 | //("type,T", po::value<std::string>(&opt.graphOutputType)->default_value("dot"), "output data format (defaults to graphviz/dot)") |
| 134 | ("show-tree,t", po::value<bool>(&opt.showTree)->default_value(true), "Whether or not to show the path tree structure") |
| 135 | ("show-aliases,a", po::value<bool>(&opt.showAliases)->default_value(false), "Whether or not to show the alias links") |
| 136 | ("full-paths,p", po::value<bool>(&opt.fullPaths)->default_value(false), "Whether or not to use a node's full path as its label") |
| 137 | ; |
| 138 | // clang-format on |
| 139 | po::variables_map vm; |
| 140 | bool usage = false; |
| 141 | try { |
| 142 | po::store(po::command_line_parser(argc, argv).options(desc).run(), |
| 143 | vm); |
| 144 | po::notify(vm); |
| 145 | } catch (std::exception &e) { |
| 146 | std::cerr << "\nError parsing command line: " << e.what() |
| 147 | << std::endl; |
| 148 | usage = true; |
| 149 | } |
| 150 | if (usage || vm.count("help")) { |
| 151 | std::cerr |
| 152 | << "\nTraverses the path tree and outputs it as input data " |
| 153 | "for a graph software package\n"; |
| 154 | std::cerr << "Usage: " << argv[0] << " [options]\n"; |
| 155 | std::cerr << desc << "\n"; |
| 156 | return 1; |
| 157 | } |
| 158 | std::ofstream file; |
| 159 | if (vm.count("output")) { |
| 160 | file.open(vm["output"].as<std::string>().c_str()); |
| 161 | if (!file) { |
| 162 | std::cerr << "Error opening output file." << std::endl; |
| 163 | return 1; |
| 164 | } |
| 165 | stream = &file; |
| 166 | } |
| 167 | return osvrToStream(*stream, opt); |
| 168 | } |
| 169 | } |
nothing calls this directly
no test coverage detected