aboutsummaryrefslogtreecommitdiff
path: root/int_slice.go
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-08-05 12:46:33 -0400
committerEric Paris <[email protected]>2015-08-05 12:54:03 -0400
commit90b831e61ee0ea159e0d00bb0c1ee3cd0c1dcdcd (patch)
tree6655dd93a25fe82dfe6362ba8c87f874158834f4 /int_slice.go
parentaf83f852cb3533df209ffef0b0f36b65d4594848 (diff)
String and Int slices called twice should append not overwrite
This allows users to do things like ``` cmd --filename=file1 --filename=file2 --filename=file3,file4 ``` And internally we will get ``` []string{"file1", "file2", "file3", "file4"} ```
Diffstat (limited to 'int_slice.go')
-rw-r--r--int_slice.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/int_slice.go b/int_slice.go
index fb3e67b..69e7e7c 100644
--- a/int_slice.go
+++ b/int_slice.go
@@ -25,7 +25,7 @@ func (s *intSliceValue) Set(val string) error {
}
}
- *s = intSliceValue(out)
+ *s = append(*s, out...)
return nil
}
@@ -38,10 +38,11 @@ func (s *intSliceValue) String() string {
for i, d := range *s {
out[i] = fmt.Sprintf("%d", d)
}
- return strings.Join(out, ",")
+ return "[" + strings.Join(out, ",") + "]"
}
func intSliceConv(val string) (interface{}, error) {
+ val = strings.Trim(val, "[]")
ss := strings.Split(val, ",")
out := make([]int, len(ss))
for i, d := range ss {