<p dir="auto">This switches parsing of command line arguments from getopt to the CLI11 library.</p>
<p dir="auto">Its adds CLI11 as a new dependency. With this commit CLI11 is vendored in in the contrib directory, because it is not available in Ubuntu 20.04 and Debian before Bookworm. It is available in Ubuntu 22.04 und Debian Bookworm and it is available in Homebrew and as vcpkg. So a bit down the line we can switch to the versions available from the OS distribution.</p>
<p dir="auto">For Windows we don't need the getopt version from alex85k any more and this commit also removes that code from the Github action setup.</p>
<p dir="auto">This commit is quite large, because we have to change everything at the same time. Changes are for osm2pgsql and osm2pgsql-gen which now share part of the option parsing code (database and logging options), in the new src/command-line-app.[ch]pp files.</p>
<p dir="auto">The code tries to keep the functionality the same as much as possible. So no extra checks on command line options or so, these can come later.</p>
<p dir="auto">There are some unavoidable changes:</p>
<ul dir="auto">
<li>Some error messages have changed</li>
<li>Help output is now generated by the CLI11 library so it looks very different. There is no verbose help version any more. All command line options are shown with --help, but some with a bit less detail than before. But all the detail is in the man page anyway.</li>
<li>CLI11 can not parse an empty option parameter, so something like "--foo=" does not work, it tries to use the next option as value for the option. This is not very relevant in the real world, but there might be some corner cases where this changes behaviour.</li>
</ul>
<p dir="auto">See <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="32627878" data-permission-text="Title is private" data-url="https://github.com/osm2pgsql-dev/osm2pgsql/issues/142" data-hovercard-type="issue" data-hovercard-url="/osm2pgsql-dev/osm2pgsql/issues/142/hovercard" href="https://github.com/osm2pgsql-dev/osm2pgsql/issues/142">#142</a></p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115'>https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/commits/482719e541d53778d8ace042108dcc801d83a90e" class="commit-link">482719e</a>  Use CLI11 command line parser library</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files">38 files</a>)</p>
<ul>
  <li>
    <strong>D</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-1c45a8d841a9f333ade283fcad9ce1a44eb5f7124bc3cbe863b924297d070e11">.github/actions/win-getopt/action.yml</a>
    (20)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03f">.github/workflows/ci.yml</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20a">CMakeLists.txt</a>
    (17)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5">README.md</a>
    (1)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-92fe1eeb066fdad7b28e883deebe5ecd0c7905700a68996eba66028ebe69f399">contrib/CLI11/LICENSE</a>
    (25)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-3a090d2237c5ebc89ac42653349c4f95329d1329d773e77099de56673e6e2ef2">contrib/CLI11/README.contrib</a>
    (2)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-84a95525b5b5808a644a4f737020d6546db4aa1f9bfa13ec6b338ea4841d76b7">contrib/CLI11/README.md</a>
    (1828)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-807d9bfe326048ce388f661354cbcb0b86e3e37f6553e9c5672c367ba1273e00">contrib/CLI11/include/CLI/App.hpp</a>
    (1399)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-497dd6674a885df39d1444e20f4078cdc832177ba48e2ed5ffbf38b98dffa49e">contrib/CLI11/include/CLI/CLI.hpp</a>
    (36)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-303c89c29822bfa965f63623e65852016802ed0a8f199182a2736c7b1b49ce1a">contrib/CLI11/include/CLI/Config.hpp</a>
    (48)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-a817efb8b75f97f17b4d0e5bf6d4a8f4fbeb89f952b56ba4bb53e1ea1b75c0a9">contrib/CLI11/include/CLI/ConfigFwd.hpp</a>
    (185)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-f22a1bf40486ee556981403924ef1d72f6e7279b141fa8a5f085e88d3107373a">contrib/CLI11/include/CLI/Error.hpp</a>
    (354)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-a83a0cc63424ec0c43904140515812ed0a0bffd53b830c4bfd05a761395414e4">contrib/CLI11/include/CLI/Formatter.hpp</a>
    (25)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-4c459eb243b6c39d8c88db5f3eeaac88ee39e0fa76ca1717a7563cb77540ac7b">contrib/CLI11/include/CLI/FormatterFwd.hpp</a>
    (189)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-87111e035f9236b1d31d9b32bded46c33c5f784ddb2e049e394a528a16bab0eb">contrib/CLI11/include/CLI/Macros.hpp</a>
    (75)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-6e4e366f98bb91fcf4ce0f4aef64fdd093483feb2c181586bdf6c91e264ff9a3">contrib/CLI11/include/CLI/Option.hpp</a>
    (807)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-2d7bec97e733bf9112b6e2797edaf5078d5d68ddccddeb9765571d7e90f697ad">contrib/CLI11/include/CLI/Split.hpp</a>
    (48)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-5ab97135981019d9bbae53bc178cd84968378a0214787655262a72621b82f7de">contrib/CLI11/include/CLI/StringTools.hpp</a>
    (234)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-d93badf9511b7ea9c20150797e426c2bdc262b4d7c353efa81921a99d2dd8b97">contrib/CLI11/include/CLI/Timer.hpp</a>
    (135)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-03dd3e931db6c966f4622445e17a829048afb4a4b39cca5f3f109a94b392b253">contrib/CLI11/include/CLI/TypeTools.hpp</a>
    (1588)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-1d61d46fb9f3deac04ae2ac5310fd314e5ae9f3eacb4cc0ea4128074ba30e692">contrib/CLI11/include/CLI/Validators.hpp</a>
    (916)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-164f5e944c593dfe75de67a5dbb7977179ad4bc0a5391d74dd07cff1b6a564a3">contrib/CLI11/include/CLI/Version.hpp</a>
    (16)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-d8213b9809dcceb448370871c545ee5d86cc2c1a25a73906de64add909889a21">contrib/CLI11/include/CLI/impl/App_inl.hpp</a>
    (2105)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-13a5490deb0e91d497a34fd9bd1d7793c9c61f1fbcf8d9ba4d59885e0e57fb0c">contrib/CLI11/include/CLI/impl/Config_inl.hpp</a>
    (395)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-977cf4715a84228e53e7670e22fc807abc96fea035fd3b943b0be04c6686dc70">contrib/CLI11/include/CLI/impl/Formatter_inl.hpp</a>
    (291)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-d8abf0307644d7a028cf138a2a8834585af64d65ece8a63cf71e367624bba0a5">contrib/CLI11/include/CLI/impl/Option_inl.hpp</a>
    (653)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-f84a0beb8103a1bac7e916b5988d33bc2abcf4f3d838b81f40ce179261a305a7">contrib/CLI11/include/CLI/impl/Split_inl.hpp</a>
    (139)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-b18bd64b7a2fa6f2ac8eeee67546c213d944dd50b5ddbf0b1f71b41022ddb80b">contrib/CLI11/include/CLI/impl/StringTools_inl.hpp</a>
    (260)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-2691d30b7ed313d412a3587c68229e8b7871277de4ee3bc4565b2a94ab9fb140">contrib/CLI11/include/CLI/impl/Validators_inl.hpp</a>
    (347)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-017756085638d9622dbeec4c76fe7de1751f22f7414f681c46eff637fabe0bf8">man/osm2pgsql-gen.md</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-148715d6ea0c0ea0a346af3f6bd610d010d490eca35ac6a9b408748f7ca9e3f4">src/CMakeLists.txt</a>
    (1)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-a06abb0c3048751111d897d6d10297d2c633c5b4f8f0fda4510efe096ea3f1de">src/command-line-app.cpp</a>
    (112)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-51dd043600471f16df179ea409bf72cad9c342ccc72bdf5aae6340289a968595">src/command-line-app.hpp</a>
    (42)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-101bbf3f8544d98c967a0220a0116b9dde497095c64ba0b72707714eaebd7397">src/command-line-parser.cpp</a>
    (977)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-af990b4913ef709327b65c38b7aa4719b2caaed25de91ebd7496daf528ac8386">src/gen/osm2pgsql-gen.cpp</a>
    (199)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-1c22a1a384d93c9c91ca44a67a64253a976fa3dc112e87596046baf9007abbf6">src/osm2pgsql.cpp</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-5b9e84c6f3c4d7cd5bba31c8ee0f5b3c7a3405c72174b76cb92713d336185e04">tests/bdd/regression/properties.feature</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115/files#diff-e0877ad9dd4ef1d9bcde29e4d6c325e14736f14fd2f50abc6ff4362689460cb4">tests/test-options-parse.cpp</a>
    (12)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115.patch'>https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115.patch</a></li>
  <li><a href='https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115.diff'>https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353URWKP2NFGB5PTGWUDYKVFFXAVCNFSM6AAAAABA7RXCO2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2TGNRRG42TSMY">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AA6353TZQ3GSC72JDLIKSBDYKVFFXA5CNFSM6AAAAABA7RXCO2WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHHUZ5XXE.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><osm2pgsql-dev/osm2pgsql/pull/2115</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115",
"url": "https://github.com/osm2pgsql-dev/osm2pgsql/pull/2115",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>