func reviewAction(ctx *cli.Context) { opts := review.Options{ Files: ctx.Args(), Diff: ctx.Bool("diff"), SaveToFile: ctx.String("save"), KeepAll: ctx.Bool("keep-all"), } issues, err := review.Review(opts) if err != nil { common.OSErrf(err.Error()) return } // TODO(waigani) I'm not happy that we're doing this here, can't find a // better place though. saveToFile := ctx.String("save") if saveToFile != "" { err := review.Save(saveToFile, issues) if err != nil { common.OSErrf("could not save to file: %s", err.Error()) return } fmt.Printf("review saved to %s\n", saveToFile) } // TODO(waigani) make more informative // TODO(waigani) if !ctx.String("quiet") fmt.Printf("Done! Found %d issues \n", len(issues)) }
func rb(ctx *cli.Context) error { if len(ctx.Args()) == 0 { return errors.Errorf("The ReviewBoard service requires at least one arguement, the review ID") } // Make sure we have a config before posting serviceName := ctx.String("config") var cfgNeedsEdit bool rbCfg, err := config.Service(serviceName) if err != nil { fmt.Printf("no configuration found for %q\n", serviceName) cfgNeedsEdit = true } else if err := validateRbCfg(rbCfg); err != nil { fmt.Printf("%q configuration file is not valid: %v\n", serviceName, err) cfgNeedsEdit = true } if cfgNeedsEdit { // TODO(waigani) send and check a typed error var edit string fmt.Printf("Would you like to configure %s now? n/Y: ", serviceName) fmt.Scanln(&edit) switch edit { case "n", "N": return errors.New("aborted") case "y", "Y", "": return config.Edit(config.ServicesCfgFile, "vi") // TODO(waigani) use default editor default: return errors.Trace(err) } return nil } opts := review.Options{ Files: ctx.Args()[1:], Diff: ctx.Bool("diff"), SaveToFile: ctx.String("save"), KeepAll: ctx.Bool("keep-all"), } issues, err := review.Review(opts) if err != nil { return errors.Trace(err) } reviewID := ctx.Args()[0] fmt.Println("Posting review to reviewboard ...") return errors.Trace(postToRB(reviewID, rbCfg, issues)) }