GNU getopt-style Go packages?

225 views
Skip to first unread message

jlfo...@berkeley.edu

unread,
Sep 4, 2021, 2:48:35 PM9/4/21
to golang-nuts
I'm wondering what the current state of GNU getopt-style Go packages is.
I've done some research and found the following:

DavidGamba / go-getoptions
alecthomas / kong
elegos / flags
jessevdk / go-flags
pborman / getopt
pborman / options
skeeto / optparse-go
spf13 / cobra
subchen / go-cli
tcler / cmdline-go
urfave / cli
vma / getopt

Some of these don't look active, and I'm sure I've missed some.

Any comments on any of the above? What have you used for command line parsing in the past, and what would you use in the future?

Cordially,
Jon Forrest
UC Berkeley (ret.)

o...@eigenstate.org

unread,
Sep 4, 2021, 10:17:52 PM9/4/21
to golan...@googlegroups.com, jlfo...@berkeley.edu
Quoth jlfo...@berkeley.edu <jlfo...@berkeley.edu>:
> Some of these don't look active, and I'm sure I've missed some.

What kind of activity are you expecting? Are you
seeing unaddressed bugs?

Command line parsing isn't hard, and it's possible
the packages are just finished.

> Any comments on any of the above? What have you used for command line
> parsing in the past, and what would you use in the future?

I just use the flags package; I don't love it, but
I also don't feel a need to pull in an additional
dependency for flag parsing.

Javier Ruano

unread,
Sep 4, 2021, 10:17:55 PM9/4/21
to jlfo...@berkeley.edu, golang-nuts
Dese Jon
I have seen this one too


Searching like argsparse
Regards
Javier Ruano


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8dd1a249-68c3-466f-a571-46b7df3b1c97n%40googlegroups.com.

Sandip Bhattacharya

unread,
Sep 7, 2021, 12:25:07 PM9/7/21
to jlfo...@berkeley.edu, golang-nuts
You probably missed pflag (https://github.com/spf13/pflag) which is what
I use for anything more than one off programs. That is not to say that
other getopt libraries are not good. Just that when I started working on
golang, I was looking for the same short-style/long-style support as you
are, and that library was really popular (it is what spf13 / cobra is
based on I think) and I have never looked back.

I used https://github.com/alecthomas/kingpin too and I liked the
fluent-style syntax. Though the author has moved on to Kong.

I use cobra for full fledged CLI apps, with subcommands, automatic
environment/config file integration (with spf13/viper).

So, based on how extensive your app is, you have many options - I just
listed mine, but again, not to say other libraries are not better.

Thanks,

  Sandip
> ** --
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/8dd1a249-68c3-466f-a571-46b7df3b1c97n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/8dd1a249-68c3-466f-a571-46b7df3b1c97n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages