MCPcopy Create free account
hub / github.com/Kitware/ParaView / ParseOptions

Method ParseOptions

Remoting/Application/vtkInitializationHelper.cxx:270–346  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

268
269//----------------------------------------------------------------------------
270bool 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());

Callers

nothing calls this directly

Calls 7

ListAttachedMonitorsFunction · 0.85
GetLastErrorMessageMethod · 0.80
GetUsageMethod · 0.80
GetHelpMethod · 0.80
FinalizeFunction · 0.50
ParseMethod · 0.45
DisplayTextMethod · 0.45

Tested by

no test coverage detected