----------------------------------------------------------------------------
| 268 | |
| 269 | //---------------------------------------------------------------------------- |
| 270 | bool vtkInitializationHelper::ParseOptions(int argc, char** argv, vtkCLIOptions* options, |
| 271 | vtkRemotingCoreConfiguration* coreConfig, bool checkForExit) |
| 272 | { |
| 273 | auto controller = vtkMultiProcessController::GetGlobalController(); |
| 274 | const auto rank0 = (controller == nullptr || controller->GetLocalProcessId() == 0); |
| 275 | |
| 276 | if (!options->Parse(argc, argv)) |
| 277 | { |
| 278 | if (rank0) |
| 279 | { |
| 280 | // report error. |
| 281 | std::ostringstream str; |
| 282 | str << options->GetLastErrorMessage().c_str() << endl |
| 283 | << options->GetUsage().c_str() << "Try `--help` for more more information." << endl; |
| 284 | vtkOutputWindow::GetInstance()->DisplayText(str.str().c_str()); |
| 285 | } |
| 286 | vtkProcessModule::Finalize(); |
| 287 | vtkInitializationHelper::ExitCode = EXIT_FAILURE; |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | if (checkForExit) |
| 292 | { |
| 293 | if (options->GetHelpRequested()) |
| 294 | { |
| 295 | if (rank0) |
| 296 | { |
| 297 | std::ostringstream str; |
| 298 | str << options->GetHelp() << endl; |
| 299 | |
| 300 | #ifndef _WIN32 |
| 301 | vtkOutputWindow::GetInstance()->DisplayText(str.str().c_str()); |
| 302 | #else |
| 303 | // Pop up a console and reopen stdin, stderr, stdout to it to display help |
| 304 | AllocConsole(); |
| 305 | FILE* fDummy; |
| 306 | freopen_s(&fDummy, "CONIN$", "r", stdin); |
| 307 | freopen_s(&fDummy, "CONOUT$", "w", stderr); |
| 308 | freopen_s(&fDummy, "CONOUT$", "w", stdout); |
| 309 | |
| 310 | std::cout << str.str() << std::endl; |
| 311 | |
| 312 | // Need user input to close the console, otherwise it will close immediately |
| 313 | std::cout << "Press any key to exit" << std::endl; |
| 314 | getch(); |
| 315 | #endif |
| 316 | } |
| 317 | vtkProcessModule::Finalize(); |
| 318 | vtkInitializationHelper::ExitCode = EXIT_SUCCESS; |
| 319 | return false; |
| 320 | } |
| 321 | else if (coreConfig->GetTellVersion()) |
| 322 | { |
| 323 | if (rank0) |
| 324 | { |
| 325 | std::ostringstream str; |
| 326 | str << "paraview version " << PARAVIEW_VERSION_FULL << "\n"; |
| 327 | vtkOutputWindow::GetInstance()->DisplayText(str.str().c_str()); |
nothing calls this directly
no test coverage detected