<div dir="ltr"><div>Hi Even.</div><div><br></div><div>In principle the idea sounds good.<br></div><div><br></div><div>How is it parsing the numbers? is it locale agnostic? I think it is not, because it is using "strtod". That means that if I have my locale in Spanish, French, German, ... it will expect "," as the decimal separator, right?</div><div>... well, how is GDAL expecting floating values? Is GDAL locale agnostic?<br></div><div><br></div><div>Do you want to add it as a dependency, or just copy-paste the header file into gdal repo?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 8 Mar 2024 at 16:40, Even Rouault via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  

    
  
  <div>
    <p>Hi,</p>
    <p>Our command line C++ utilities use ad-hoc manual parsing, which
      means that:</p>
    <p>-  the usage message must be manually composed, </p>
    <p>-  you must take care to check that there are enough remaining
      arguments for the ones that take value to avoid out-of-bounds
      accesses (tests like argc + 1 < argn) </p>
    <p>- detection for duplicated arguments when only a single
      occurrence is allowed must be manually done, nd thus is often not
      done, confusing users, cf
      <a href="https://github.com/OSGeo/gdal/issues/9415" target="_blank">https://github.com/OSGeo/gdal/issues/9415</a></p>
    <p>- etc.<br>
    </p>
    <p>I've come across <a href="https://github.com/p-ranav/argparse" target="_blank">https://github.com/p-ranav/argparse</a> which fit
      all my requirements at first sight: compatible with our C++
      requirements (C++17), MIT license, easily usable (single header),
      well documented, and enough feature-full. From a quick testing, it
      seems to work well. It looks also as it has taken some inspiration
      from the Python argparse module.<br>
    </p>
    <p>I'd be tempted to give that a try to retrofit our existing
      utilities (probably starting with the ones with the less options
      :-)). Opinions? I guess there must be a plethora of similar
      projects, due to the absence of a std::argparse module... At least
      I see it is in the list of (9) alternatives mentioned at
<a href="https://en.cppreference.com/w/cpp/links/libs?source=post_page---------------------------#Configuration:Command_Line" target="_blank">https://en.cppreference.com/w/cpp/links/libs?source=post_page---------------------------#Configuration:Command_Line</a></p>
    <p>CLI11 looked like a candidate too, but reading
<a href="https://github.com/CLIUtils/CLI11?tab=readme-ov-file#features-not-supported-by-this-library" target="_blank">https://github.com/CLIUtils/CLI11?tab=readme-ov-file#features-not-supported-by-this-library</a>
      "There are some other possible "features" that are intentionally
      not supported by
      this library:... Non-standard variations on syntax, like <code>-long</code>
      options. This is non-standard
      and should be avoided, so that is enforced by this library." .
      Fair enough, but we use that extensively in GDAL.<br>
    </p>
    <p>Even<br>
    </p>
    <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>