remove control flow on errExit by switching from bool to int

pull/522/head
Ali Abbas 10 years ago
parent a030abdefc
commit a84a88b3f5

@ -144,14 +144,18 @@ func (c *WatchCommand) Run(args []string) int {
} }
// Setup handler // Setup handler
errExit := false
// errExit:
// 0: false
// 1: true
errExit := 0
if script == "" { if script == "" {
wp.Handler = func(idx uint64, data interface{}) { wp.Handler = func(idx uint64, data interface{}) {
defer wp.Stop() defer wp.Stop()
buf, err := json.MarshalIndent(data, "", " ") buf, err := json.MarshalIndent(data, "", " ")
if err != nil { if err != nil {
c.Ui.Error(fmt.Sprintf("Error encoding output: %s", err)) c.Ui.Error(fmt.Sprintf("Error encoding output: %s", err))
errExit = true errExit = 1
} }
c.Ui.Output(string(buf)) c.Ui.Output(string(buf))
} }
@ -186,7 +190,7 @@ func (c *WatchCommand) Run(args []string) int {
return return
ERR: ERR:
wp.Stop() wp.Stop()
errExit = true errExit = 1
} }
} }
@ -203,12 +207,7 @@ func (c *WatchCommand) Run(args []string) int {
return 1 return 1
} }
// Handle an error exit return errExit
if errExit {
return 1
} else {
return 0
}
} }
func (c *WatchCommand) Synopsis() string { func (c *WatchCommand) Synopsis() string {

Loading…
Cancel
Save