Fixed mishandling of a "-"(dash)-argument causing reordering of cli non-flag arguments.

Added test demonstrating issue (PASS with fix, FAIL without).
This commit is contained in:
Andreas Kupries
2016-01-26 15:34:53 -08:00
parent f9cc3001e0
commit bb4e78eb6a
2 changed files with 21 additions and 0 deletions

View File

@@ -81,6 +81,9 @@ func (c Command) Run(ctx *Context) (err error) {
if arg == "--" {
terminatorIndex = index
break
} else if arg == "-" {
// Do nothing. A dash alone is not really a flag.
continue
} else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 {
firstFlagIndex = index
}