Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: common/flag/stringlistflag/stringlistflag.go

Issue 2107283002: kitchen: add -python-path (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/cmd/kitchen/cook.go ('k') | common/flag/stringlistflag/stringlistflag_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« no previous file with comments | « client/cmd/kitchen/cook.go ('k') | common/flag/stringlistflag/stringlistflag_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698