-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Checklist
- Are you running the latest v2 release? The list of releases is here.
- Did you check the manual for your release? The v2 manual is here
- Did you perform a search about this feature? Here's the Github guide about searching.
What problem does this solve?
I am writing a program which is invoked by another program (openvpn up-script) and it is invoked in a very specific way. I really like this library, so I'd like to be able to use it as a command line parser. The problem is that it seems that all flags must appear before all options.
In my specific case, openvpn will always call your script with exactly 10 arguments, then you can configure it to pass additional arguments. This would result in an os.Args similar to this:
{"tun0", "1", "2"..."10", "--flush"}. The --flush is the flag that I'd like to be able to process with this library.
It seems like all flags either take no arguments (BoolFlag) or take one arugment (StringFlag).
I've needed this for other projects, but having it for this project would be really great.
Solution description
an os.Args value of {"a", "--bool-flag", "--string-flag", "abc", "b"} should have:
ctx.Args() --> {"a", "b"}ctx.BoolFlag("bool-flag") --> truectx.StringFlag("string-flag") --> "abc"
Describe alternatives you've considered
Not using this library for some of my projects