Skip to content

Commit

Permalink
Merge pull request #54 from tknzk/codegangsta_cli_deprecated_method
Browse files Browse the repository at this point in the history
fix signnatures. codegangsta/cli
  • Loading branch information
Songmu committed May 19, 2016
2 parents 23c80a9 + 7554714 commit d3f6de9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
8 changes: 5 additions & 3 deletions alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func formatJoinedAlert(alertSet *alertSet, colorize bool) string {
return fmt.Sprintf("%s %s %s %s%s", alert.ID, time.Unix(alert.OpenedAt, 0).Format(layout), statusMsg, monitorMsg, hostMsg)
}

func doAlertsRetrieve(c *cli.Context) {
func doAlertsRetrieve(c *cli.Context) error {
conffile := c.GlobalString("conf")
client := newMackerel(conffile)

Expand All @@ -191,7 +191,7 @@ func doAlertsRetrieve(c *cli.Context) {
return
}

func doAlertsList(c *cli.Context) {
func doAlertsList(c *cli.Context) error {
conffile := c.GlobalString("conf")
filterServices := c.StringSlice("service")
filterStatuses := c.StringSlice("host-status")
Expand Down Expand Up @@ -230,9 +230,10 @@ func doAlertsList(c *cli.Context) {
}
fmt.Println(formatJoinedAlert(joinAlert, c.BoolT("color")))
}
return nil
}

func doAlertsClose(c *cli.Context) {
func doAlertsClose(c *cli.Context) error {
conffile := c.GlobalString("conf")
isVerbose := c.Bool("verbose")
argAlertIDs := c.Args()
Expand All @@ -253,4 +254,5 @@ func doAlertsClose(c *cli.Context) {
PrettyPrintJSON(alert)
}
}
return nil
}
21 changes: 14 additions & 7 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ OPTIONS:
{{end}}`
}

func doStatus(c *cli.Context) {
func doStatus(c *cli.Context) error {
conffile := c.GlobalString("conf")
argHostID := c.Args().Get(0)
isVerbose := c.Bool("verbose")
Expand Down Expand Up @@ -264,9 +264,10 @@ func doStatus(c *cli.Context) {

PrettyPrintJSON(format)
}
return nil
}

func doHosts(c *cli.Context) {
func doHosts(c *cli.Context) error {
conffile := c.GlobalString("conf")
isVerbose := c.Bool("verbose")

Expand Down Expand Up @@ -303,9 +304,10 @@ func doHosts(c *cli.Context) {

PrettyPrintJSON(hostsFormat)
}
return nil
}

func doCreate(c *cli.Context) {
func doCreate(c *cli.Context) error {
conffile := c.GlobalString("conf")
argHostName := c.Args().Get(0)
optRoleFullnames := c.StringSlice("roleFullname")
Expand All @@ -331,9 +333,10 @@ func doCreate(c *cli.Context) {
logger.DieIf(err)
logger.Log("updated", fmt.Sprintf("%s %s", hostID, optStatus))
}
return nil
}

func doUpdate(c *cli.Context) {
func doUpdate(c *cli.Context) error {
conffile := c.GlobalString("conf")
argHostIDs := c.Args()
optName := c.String("name")
Expand Down Expand Up @@ -393,9 +396,10 @@ func doUpdate(c *cli.Context) {

logger.Log("updated", hostID)
}
return nil
}

func doThrow(c *cli.Context) {
func doThrow(c *cli.Context) error {
conffile := c.GlobalString("conf")
optHostID := c.String("host")
optService := c.String("service")
Expand Down Expand Up @@ -453,9 +457,10 @@ func doThrow(c *cli.Context) {
cli.ShowCommandHelp(c, "throw")
os.Exit(1)
}
return nil
}

func doFetch(c *cli.Context) {
func doFetch(c *cli.Context) error {
conffile := c.GlobalString("conf")
argHostIDs := c.Args()
optMetricNames := c.StringSlice("name")
Expand All @@ -469,9 +474,10 @@ func doFetch(c *cli.Context) {
logger.DieIf(err)

PrettyPrintJSON(metricValues)
return nil
}

func doRetire(c *cli.Context) {
func doRetire(c *cli.Context) error {
conffile := c.GlobalString("conf")
force := c.Bool("force")
argHostIDs := c.Args()
Expand All @@ -497,4 +503,5 @@ func doRetire(c *cli.Context) {

logger.Log("retired", hostID)
}
return nil
}
13 changes: 8 additions & 5 deletions monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,17 @@ func monitorLoadRules(optFilePath string) ([]*(mkr.Monitor), error) {
return data.Monitors, nil
}

func doMonitorsList(c *cli.Context) {
func doMonitorsList(c *cli.Context) error {
conffile := c.GlobalString("conf")

monitors, err := newMackerel(conffile).FindMonitors()
logger.DieIf(err)

PrettyPrintJSON(monitors)
return nil
}

func doMonitorsPull(c *cli.Context) {
func doMonitorsPull(c *cli.Context) error {
conffile := c.GlobalString("conf")
isVerbose := c.Bool("verbose")
filePath := c.String("file-path")
Expand All @@ -130,6 +131,7 @@ func doMonitorsPull(c *cli.Context) {
filePath = "monitors.json"
}
logger.Log("info", fmt.Sprintf("Monitor rules are saved to '%s' (%d rules).", filePath, len(monitors)))
return nil
}

func isEmpty(a interface{}) bool {
Expand Down Expand Up @@ -368,7 +370,7 @@ func checkMonitorsDiff(c *cli.Context) monitorDiff {
return monitorDiff
}

func doMonitorsDiff(c *cli.Context) {
func doMonitorsDiff(c *cli.Context) error {
monitorDiff := checkMonitorsDiff(c)
isExitCode := c.Bool("exit-code")

Expand All @@ -394,9 +396,10 @@ func doMonitorsDiff(c *cli.Context) {
if isExitCode == true && noDiff == false {
os.Exit(1)
}
return nil
}

func doMonitorsPush(c *cli.Context) {
func doMonitorsPush(c *cli.Context) error {
monitorDiff := checkMonitorsDiff(c)
isDryRun := c.Bool("dry-run")
isVerbose := c.Bool("verbose")
Expand Down Expand Up @@ -431,5 +434,5 @@ func doMonitorsPush(c *cli.Context) {
logger.DieIf(err)
}
}

return nil
}

0 comments on commit d3f6de9

Please sign in to comment.