fix issue 89 (multiple args terminated by "--")
This commit is contained in:
parent
8baf7040d7
commit
233d378a50
2
parse.go
2
parse.go
|
@ -502,7 +502,7 @@ func (p *Parser) process(args []string) error {
|
|||
if spec.multiple {
|
||||
var values []string
|
||||
if value == "" {
|
||||
for i+1 < len(args) && !isFlag(args[i+1]) {
|
||||
for i+1 < len(args) && !isFlag(args[i+1]) && args[i+1] != "--" {
|
||||
values = append(values, args[i+1])
|
||||
i++
|
||||
if spec.separate {
|
||||
|
|
|
@ -1045,3 +1045,15 @@ func TestVersion(t *testing.T) {
|
|||
assert.Equal(t, ErrVersion, err)
|
||||
|
||||
}
|
||||
|
||||
func TestMultipleTerminates(t *testing.T) {
|
||||
var args struct {
|
||||
X []string
|
||||
Y string `arg:"positional"`
|
||||
}
|
||||
|
||||
err := parse("--x a b -- c", &args)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []string{"a", "b"}, args.X)
|
||||
assert.Equal(t, "c", args.Y)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue