New library: argparse, for parsing CLI arguments
Bill Baxter
wbaxter at gmail.com
Thu Oct 14 02:09:35 UTC 2021
On Wed, Oct 13, 2021 at 6:15 PM Andrey Zherikov via Digitalmars-d-announce <
digitalmars-d-announce at puremagic.com> wrote:
> On Thursday, 14 October 2021 at 00:35:11 UTC, Bill Baxter wrote:
> > On Wed, Oct 13, 2021 at 5:30 PM Andrey Zherikov via
> > Digitalmars-d-announce < digitalmars-d-announce at puremagic.com>
> > wrote:
> >
> >> On Wednesday, 13 October 2021 at 19:26:49 UTC, Andrei
> >> Alexandrescu wrote:
> >> > Cool!
> >> >
> >> > One note - gflags
> >> > (https://opensource.google/projects/gflags) allows modules
> >> > to define their own flags in a decentralized manner. I've
> >> > always thought this is a major feature missing from
> >> > std.getopt, but never got around to it. It would be great if
> >> > argparse would add such support.
> >>
> >> This is an interesting approach. I'm not a fan of it but I'll
> >> take a look at whether this can be supported.
> >>
> >
> > Not sure how much change there is over "classic" gflags, but
> > https://abseil.io/docs/cpp/guides/flags is what google now uses
> > internally.
> >
> > --bb
>
> Abseil version suggests not to put flags into multiple .cpp files:
> - `Allows distributed declaration and definition of flags, though
> this usage has drawbacks and should generally be avoided`
> - `Prefer to define flags only in the file containing the
> binary’s main() function`
> - `Prefer to reference flags only from within the file containing
> the binary’s main() function`
>
> So I'm a bit confused about supporting this use case
>
Yeh, it's definitely a mixed bag. It can be very convenient to be able to
put the flag right near point of use without having to do any plumbing.
But sometimes it can be frustrating given that "flags" are essentially a
single global namespace that people don't always realize is a global
namespace. Quite annoying when you go to add something like a
"--start_time" flag and find that some random .cc file in a library already
defines that flag for their own purposes.
--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20211013/8de8a595/attachment.htm>
More information about the Digitalmars-d-announce
mailing list