droundy/goopt — pull request #5 by tianon (2012-10-17 02:05:52+00:00)
Title: RequireOrder

I've added a RequireOrder option that mimics the "require_order" configuration flag for Getopt::Long in Perl (http://perldoc.perl.org/Getopt/Long.html#require_order), which makes the module able to be more "POSIXLY_CORRECT", and opens up the possibility of doing partial processing (ala git itself having global git flags and then more local subcommand flags later on).

I think a very nice compliment to this option would be a way to specify an arbitrary slice to parse in place of os.Args so that this really could be run multiple times for subcommands and the like, although then we run into scoping issues of not wanting previously defined flags to be processed on the second run (which is why a commit for that change isn't included here also). A solution I would propose for that (and would love some dialog about) would be a "GoOpt" struct/object that contains all the options parsing but includes a backwards-compatible interface that just uses a shared object. If you like the idea, I'd really enjoy implementing such a thing and sending another pull request when it is complete.