Closed uuuvn closed 2 years ago
Yep. It is supported to get TrailingArguments, as well as Positional Arguments...
In your example, install
would be a Subcommand
. pkg1
, pkg2
, pkg3
would be TrailingArguments
.
You can get TrailingArguments
with flaggy.TrailingArguments[0]
.
So, i need to do something like: mycoolpackagemanager install -- coolpackage1 coolpackage2 coolpackageN ? Is it possible without '--'?
I had no problems with getopt-long in C, and I was surprised to notice that with all sorts of unnecessary bloat libraries, there is no "perfect" argument parser in go. Flaggy is the closest to the ideal, but things like this (and dynamically linked 2.5 megabyte binary) scare me away from go
The binary for go is bigger, but the go runtime contains a ton of good stuff for concurrency, garbage collection, and thread handling...
I actually just tested this because I wasn't 100% sure anymore, and noticed bad behavior wherein trailing arguments were not set as I would have expected them to be... Checking it out when I get a moment.
Fixed in tag v1.5.2!
go get -u github.com/integrii/flaggy
Thanks!
A simple example: mycoolpackagemanager install pkg1 pkg2 pkg3 ... pkgN Is this supported? I didn't find anything about this