command/watch: Changes for event watch

This commit is contained in:
Armon Dadgar 2014-08-28 15:51:12 -07:00
parent 175de542bc
commit 3b01d24376

View file

@ -41,6 +41,7 @@ Options:
Watch Specification: Watch Specification:
-key=val Specifies the key to watch. Only for 'key' type. -key=val Specifies the key to watch. Only for 'key' type.
-name=val Specifies an event name to watch. Only for 'event' type.
-passingonly=[true|false] Specifies if only hosts passing all checks are displayed. -passingonly=[true|false] Specifies if only hosts passing all checks are displayed.
Optional for 'service' type. Defaults false. Optional for 'service' type. Defaults false.
-prefix=val Specifies the key prefix to watch. Only for 'keyprefix' type. -prefix=val Specifies the key prefix to watch. Only for 'keyprefix' type.
@ -50,13 +51,13 @@ Watch Specification:
-tag=val Specifies the service tag to filter on. Optional for 'service' -tag=val Specifies the service tag to filter on. Optional for 'service'
type. type.
-type=val Specifies the watch type. One of key, keyprefix -type=val Specifies the watch type. One of key, keyprefix
services, nodes, service, or checks. services, nodes, service, checks, or event.
` `
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }
func (c *WatchCommand) Run(args []string) int { func (c *WatchCommand) Run(args []string) int {
var watchType, datacenter, token, key, prefix, service, tag, passingOnly, state string var watchType, datacenter, token, key, prefix, service, tag, passingOnly, state, name string
cmdFlags := flag.NewFlagSet("watch", flag.ContinueOnError) cmdFlags := flag.NewFlagSet("watch", flag.ContinueOnError)
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) } cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }
cmdFlags.StringVar(&watchType, "type", "", "") cmdFlags.StringVar(&watchType, "type", "", "")
@ -68,6 +69,7 @@ func (c *WatchCommand) Run(args []string) int {
cmdFlags.StringVar(&tag, "tag", "", "") cmdFlags.StringVar(&tag, "tag", "", "")
cmdFlags.StringVar(&passingOnly, "passingonly", "", "") cmdFlags.StringVar(&passingOnly, "passingonly", "", "")
cmdFlags.StringVar(&state, "state", "", "") cmdFlags.StringVar(&state, "state", "", "")
cmdFlags.StringVar(&name, "name", "", "")
httpAddr := HTTPAddrFlag(cmdFlags) httpAddr := HTTPAddrFlag(cmdFlags)
if err := cmdFlags.Parse(args); err != nil { if err := cmdFlags.Parse(args); err != nil {
return 1 return 1
@ -110,6 +112,9 @@ func (c *WatchCommand) Run(args []string) int {
if state != "" { if state != "" {
params["state"] = state params["state"] = state
} }
if name != "" {
params["name"] = name
}
if passingOnly != "" { if passingOnly != "" {
b, err := strconv.ParseBool(passingOnly) b, err := strconv.ParseBool(passingOnly)
if err != nil { if err != nil {