Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
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.
 
 
 
 
 
 

37 lines
652 B

package flags
import (
"flag"
"fmt"
"strings"
)
// Ensure implements
var _ flag.Value = (*FlagMapValue)(nil)
// FlagMapValue is a flag implementation used to provide key=value semantics
// multiple times.
type FlagMapValue map[string]string
func (h *FlagMapValue) String() string {
return fmt.Sprintf("%v", *h)
}
func (h *FlagMapValue) Set(value string) error {
idx := strings.Index(value, "=")
if idx == -1 {
return fmt.Errorf("Missing \"=\" value in argument: %s", value)
}
key, value := value[0:idx], value[idx+1:]
if *h == nil {
*h = make(map[string]string)
}
headers := *h
headers[key] = value
*h = headers
return nil
}