# Command line argument parsing

**URL:** https://discourse.paraview.org/t/command-line-argument-parsing/4490
**Category:** Development
**Tags:** proposal
**Created:** [June 3, 2020, 1:02pm UTC](https://discourse.paraview.org/t/command-line-argument-parsing/4490 "2020-06-03T13:02:50Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [May 13, 2021, 5:28pm UTC](https://discourse.paraview.org/t/command-line-argument-parsing/4490/21 "2021-05-13T17:28:20Z")

</div>

Here’s an MR that adds CLI11 to VTK: [https://gitlab.kitware.com/vtk/vtk/-/pipelines/228604](https://gitlab.kitware.com/vtk/vtk/-/pipelines/228604)

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [May 19, 2021, 1:43pm UTC](https://discourse.paraview.org/t/command-line-argument-parsing/4490/22 "2021-05-19T13:43:55Z")

</div>

Here a work-in-progress MR: [https://gitlab.kitware.com/paraview/paraview/-/merge\_requests/4951](https://gitlab.kitware.com/paraview/paraview/-/merge_requests/4951)

Currently, the design is as such:

- ParaView components (and ParaView-based applications) can depend on arbitrary run-time configuration options. These options are to be treated as set-once-never-modified in the lifetime of the process and setup during process startup. The code can use these options to control runtime behavior.  
For example, `vtkRemotingCoreConfiguration` class provides options that affect how process module and other core Paraview remoting components are initialized. `vtkRemotingServerManagerConfiguration` class provides options that affect ServerManager operation / initialization etc. One can concieve similar configuration classes for the each of the executables to support additional configuration options.

- All these configuration classes are singletons.

- `vtkCLIOptions` is a class that wraps `CLI::App` and it intended to handle building and processing on command line arguments. Each of the configuration classes provides a `PopulateOptions` method that takes a `vtkCLIOptions` instance that it then populates with command line arguments for each of the available option.  
A typical executable, has the following code to parse args:

```auto
vtkNew<vtkCLIOptions> options;
options->SetName("TestRemotingCoreConfiguration");
options->SetDescription("Test for 'vtkRemotingCoreConfiguration'");

/**
* We can provides a `paraview::PopulateOptions(...)`,
* `pvbatch::PopulateOptions(..)` etc. as convenience methods to populate all supported
* options for each standard executable in ParaView.
*/
vtkRemotingCoreConfiguration::GetInstance()->PopulateOptions(options);
vtkRemotingServerManagerConfiguration::GetInstance()->PopulateOptions(options);
...

/**
* For ParaView-based applications, they can do
* the following to add new options
*/
MyCustomConfiguration::GetInstance()->PopulateOptions(options);

if (options->Parse(argc, argv))
{
    // parsing successful.
}

```

- For backwards compatibility, the `vtkPVOptions` instance will be initialized using values in each of the `*Configuration` classes and thus old code depending on `vtkPVOptions` will continue to work.

Thoughts? Suggestions?

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 1, 2021, 11:44am UTC](https://discourse.paraview.org/t/command-line-argument-parsing/4490/23 "2021-07-01T11:44:33Z")

</div>

Just an update, these changes are now in `master`. ParaView-based custom applications will be impacted by this change. So please feel free to raise any questions on the forum that you may have regarding the necessary changes.

[Previous page](https://discourse.paraview.org/t/command-line-argument-parsing/4490.md?page=1)
