|
@@ -20,18 +20,17 @@ import (
|
|
|
"github.com/coreos/etcd/pkg/types"
|
|
"github.com/coreos/etcd/pkg/types"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// URLsValue wraps "types.URLs".
|
|
|
type URLsValue types.URLs
|
|
type URLsValue types.URLs
|
|
|
|
|
|
|
|
// Set parses a command line set of URLs formatted like:
|
|
// Set parses a command line set of URLs formatted like:
|
|
|
// http://127.0.0.1:2380,http://10.1.1.2:80
|
|
// http://127.0.0.1:2380,http://10.1.1.2:80
|
|
|
func (us *URLsValue) Set(s string) error {
|
|
func (us *URLsValue) Set(s string) error {
|
|
|
- strs := strings.Split(s, ",")
|
|
|
|
|
- nus, err := types.NewURLs(strs)
|
|
|
|
|
|
|
+ ss, err := types.NewURLs(strings.Split(s, ","))
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- *us = URLsValue(nus)
|
|
|
|
|
|
|
+ *us = URLsValue(ss)
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -43,9 +42,14 @@ func (us *URLsValue) String() string {
|
|
|
return strings.Join(all, ",")
|
|
return strings.Join(all, ",")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func NewURLsValue(init string) *URLsValue {
|
|
|
|
|
|
|
+// NewURLsValue implements "url.URL" slice as flag.Value interface.
|
|
|
|
|
+// Given value is to be separated by comma.
|
|
|
|
|
+func NewURLsValue(s string) *URLsValue {
|
|
|
|
|
+ if s == "" {
|
|
|
|
|
+ return &URLsValue{}
|
|
|
|
|
+ }
|
|
|
v := &URLsValue{}
|
|
v := &URLsValue{}
|
|
|
- if err := v.Set(init); err != nil {
|
|
|
|
|
|
|
+ if err := v.Set(s); err != nil {
|
|
|
plog.Panicf("new URLsValue should never fail: %v", err)
|
|
plog.Panicf("new URLsValue should never fail: %v", err)
|
|
|
}
|
|
}
|
|
|
return v
|
|
return v
|