Command line argument parsing

Is it time to rework the command line parsing to be bit cleaner? The current vtkPVOptions implementation is quite dated.

cxxopts seems like a very elegant choice. It also has mechanism to group options into categories, thus making it easier to parse --help output. Here’s an output from an another test program using cxxopts

> ./demo --help
  ./demo [OPTION...]

  -h, --help  help

 Mode options:
  -s, --server  run as server
      --hybrid  run as client and server

 Client options:
  -u, --url arg  address for server to connect to (default:

+1 for cxxopts !

We are using it at F3D. Well, a slightly modified version for our needs, and are quite happy with it.
We especially like the way it handles defaults values / no values, letting us use this kind of mechanism :

demo --activate-option : run and activate an option with a default value
demo --activate-option=value : run and activate an option with a user provided value

In the case of ParaView, that would remove the need for --stereo-type for example.

It means however that ParaView will loose retro compatibility with old scripts, so we may need to provide a CMake-enablable compatibility/deprecration layer for a few versions.

FYI @Michael @Joachim_Pouderoux

+1 from me. I have a few examples in the VTKExamples that will really benefit from this. It will benefit many users, especially for those coming from a Python background where this is second nature.

Good point! We should probably add it to VTK itself and update tests/examples to start using it too.

I like cxxopts. The one thing I can recall is it needs support for gcc 4.9 or greater. If I recall correctly you currently support gcc 4.8.5 with 5.8.0. Might be an issue as I know a few folks still use 4.8.5 with ParaView given the latest round of issues when 5.8.0 came out.

good point. I don’t think this will be happening for 5.9, maybe 5.10 at the earliest. By then we may be able to revise the minimum supported gcc versions.

1 Like