| Index: common/flag/stringlistflag/stringlistflag.go
|
| diff --git a/common/flag/stringsetflag/stringsetflag.go b/common/flag/stringlistflag/stringlistflag.go
|
| similarity index 52%
|
| copy from common/flag/stringsetflag/stringsetflag.go
|
| copy to common/flag/stringlistflag/stringlistflag.go
|
| index 798d70cf87982cb83c436f8836503a5e1c234694..7cbe0279f656970e49f51d476067cb824ce7d642 100644
|
| --- a/common/flag/stringsetflag/stringsetflag.go
|
| +++ b/common/flag/stringlistflag/stringlistflag.go
|
| @@ -2,20 +2,17 @@
|
| // Use of this source code is governed under the Apache License, Version 2.0
|
| // that can be found in the LICENSE file.
|
|
|
| -// Package stringsetflag provides a flag.Value implementation which resolves
|
| -// multiple args into a stringset.
|
| -package stringsetflag
|
| +// Package stringlistflag provides a flag.Value implementation which resolves
|
| +// multiple args into a []string.
|
| +package stringlistflag
|
|
|
| import (
|
| "flag"
|
| "fmt"
|
| - "sort"
|
| "strings"
|
| -
|
| - "github.com/luci/luci-go/common/stringset"
|
| )
|
|
|
| -// Flag is a flag.Value implementation which represents an unordered set of
|
| +// Flag is a flag.Value implementation which represents an ordered set of
|
| // strings.
|
| //
|
| // For example, this allows you to construct a flag that would behave like:
|
| @@ -23,18 +20,13 @@ import (
|
| // -myflag Bar
|
| // -myflag Bar
|
| //
|
| -// And then myflag.Data.Has("Bar") would be true.
|
| -type Flag struct{ Data stringset.Set }
|
| +// And then myflag would be []string{"Foo", "Bar", "Bar"}
|
| +type Flag []string
|
|
|
| var _ flag.Value = (*Flag)(nil)
|
|
|
| func (f Flag) String() string {
|
| - if f.Data == nil {
|
| - return ""
|
| - }
|
| - slc := f.Data.ToSlice()
|
| - sort.Strings(slc)
|
| - return strings.Join(slc, ",")
|
| + return strings.Join(f, ", ")
|
| }
|
|
|
| // Set implements flag.Value's Set function.
|
| @@ -43,10 +35,6 @@ func (f *Flag) Set(val string) error {
|
| return fmt.Errorf("must have an argument value")
|
| }
|
|
|
| - if f.Data == nil {
|
| - f.Data = stringset.NewFromSlice(val)
|
| - } else {
|
| - f.Data.Add(val)
|
| - }
|
| + *f = append(*f, val)
|
| return nil
|
| }
|
|
|