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.
Crowdin/types.go

29 lines
563 B

package main
import "encoding/json"
// StringMapFlag represents a string-based map as a cli flag
type StringMapFlag struct {
parts map[string]string
}
// String is implemented from cli
func (s *StringMapFlag) String() string {
return ""
}
// Get returns the parsed map
func (s *StringMapFlag) Get() map[string]string {
return s.parts
}
// Set parses the map (via json)
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
}