On Thu, Jun 26, 2025 at 10:44 AM Bruno Haible <br...@clisp.org> wrote: > > Ben Pfaff wrote: > > Another approach would be to provide a function that dynamically > > generates the shortopts > > argument to pass getopt_long(), given the long options. Then there > > would be less work and > > less to keep consistent for developers. > > I like this idea, and was thinking in the same direction, because > the missing consistency check between long and short options is only > one of the nine (!) shortcomings of the getopt_long() API. > > What do you think about the attached proposed API? Feedback welcome.
I think the API is fine, at first glance. I used a simpler long-to-short conversion in a previous (non-GNU) project. It worked OK there. Your API is more complete: https://github.com/openvswitch/ovs/blob/main/lib/command-line.c#L30-L54