You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
405 B
25 lines
405 B
7 years ago
|
package main
|
||
|
|
||
|
import "encoding/json"
|
||
|
|
||
|
type StringMapFlag struct {
|
||
|
parts map[string]string
|
||
|
}
|
||
|
|
||
|
func (s *StringMapFlag) String() string {
|
||
|
return ""
|
||
|
}
|
||
|
|
||
|
func (s *StringMapFlag) Get() map[string]string {
|
||
|
return s.parts
|
||
|
}
|
||
|
|
||
|
func (s *StringMapFlag) Set(value string) error {
|
||
|
s.parts = map[string]string{}
|
||
|
err := json.Unmarshal([]byte(value), &s.parts)
|
||
|
if err != nil {
|
||
|
s.parts["*"] = value
|
||
|
}
|
||
|
return nil
|
||
|
}
|