| 140 | }; |
| 141 | |
| 142 | int main(int argc, char *argv[]) { |
| 143 | Options opts; |
| 144 | namespace po = boost::program_options; |
| 145 | // clang-format off |
| 146 | po::options_description desc("Options"); |
| 147 | desc.add_options() |
| 148 | ("help,h", "produce help message") |
| 149 | ("show-alias-source", po::value<bool>(&opts.showAliasSource)->default_value(true), "Whether or not to show the source associated with each alias") |
| 150 | ("show-alias-priority", po::value<bool>(&opts.showAliasPriority)->default_value(false), "Whether or not to show the priority associated with each alias") |
| 151 | ("show-device-details", po::value<bool>(&opts.showDeviceDetails)->default_value(true), "Whether or not to show the basic details associated with each device") |
| 152 | ("show-device-descriptors", po::value<bool>(&opts.showDeviceDescriptor)->default_value(false), "Whether or not to show the JSON descriptors associated with each device") |
| 153 | ("show-sensors", po::value<bool>(&opts.showSensors)->default_value(true), "Whether or not to show the 'sensor' nodes") |
| 154 | ("show-string-data", po::value<bool>(&opts.showStringData)->default_value(true), "Whether or not to show the data in 'string' nodes") |
| 155 | ; |
| 156 | // clang-format on |
| 157 | po::variables_map vm; |
| 158 | bool usage = false; |
| 159 | try { |
| 160 | po::store(po::command_line_parser(argc, argv) |
| 161 | .options(desc) |
| 162 | .extra_parser(osvr::util::convertHideIntoFalseShow) |
| 163 | .run(), |
| 164 | vm); |
| 165 | po::notify(vm); |
| 166 | } catch (std::exception &e) { |
| 167 | std::cerr << "\nError parsing command line: " << e.what() << "\n\n"; |
| 168 | usage = true; |
| 169 | } |
| 170 | if (usage || vm.count("help")) { |
| 171 | std::cerr |
| 172 | << "\nTraverses the path tree and outputs it as text for " |
| 173 | "human consumption. See\n" |
| 174 | "PathTreeExport for structured output for graphical display.\n"; |
| 175 | std::cerr << "Usage: " << argv[0] << " [options]\n\n"; |
| 176 | std::cerr << "All --show options have a matching --hide option.\n\n"; |
| 177 | std::cerr << desc << "\n"; |
| 178 | return 1; |
| 179 | } |
| 180 | |
| 181 | osvr::common::PathTree pathTree; |
| 182 | { |
| 183 | /// We only actually need the client open for long enough to get the |
| 184 | /// path tree and clone it. |
| 185 | osvr::clientkit::ClientContext context("com.osvr.tools.printtree"); |
| 186 | |
| 187 | if (!context.checkStatus()) { |
| 188 | std::cerr << "Client context has not yet started up - waiting. Make sure the server is running." << std::endl; |
| 189 | do { |
| 190 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); |
| 191 | context.update(); |
| 192 | } while (!context.checkStatus()); |
| 193 | std::cerr << "OK, client context ready. Proceeding." << std::endl; |
| 194 | } |
| 195 | /// Get a non-const copy of the path tree. |
| 196 | osvr::common::clonePathTree(context.get()->getPathTree(), pathTree); |
| 197 | /// Resolve all aliases |
| 198 | osvr::common::resolveFullTree(pathTree); |
| 199 | } |
nothing calls this directly
no test coverage detected