p-ranav / argparse

Argument Parser for Modern C++
MIT License
2.72k stars 250 forks source link

Add a dry_run argument to Argument::consume(), and change ArgumentParser private section to protected #332

Closed rouault closed 8 months ago

rouault commented 8 months ago

Both changes are needed in the special case of GDAL where our existing hand-made argument parser accepts positional arguments placed anywhere in the arguments, not just after optional arguments.

In the GDAL code, in https://github.com/OSGeo/gdal/pull/9445/commits/8bb3455eedb658b55911f33fe272b8045f85f2ec#diff-4592e7daae8543536dbeadf05a3c110282ea0fc089216186138c923a0d4d8000R170 , I've implemented a preliminary pass before calling ArgumentParser::process_args() that re-order arguments. For that, I need to be able to call consume() but without side-effects (dry_run=False) and accept members that are private