func parseFlags() error { flag.Parse() validArgs := true errorMsg := "" if style == "" { validArgs = false errorMsg = "Missing `style` argument." } else if style != "stress" && style != "real" { validArgs = false errorMsg = "Invalid `style` argument passed to program: " + style + ". The only acceptable values are \"stress\" and \"real\"." } else if opsFilename == "" { validArgs = false errorMsg = "Missing required `ops_filename` argument." } else if workers <= 0 { validArgs = false errorMsg = "The `workers` argument must be a positive number." } if !validArgs { fmt.Println(errorMsg) fmt.Println("\nUsage:") flag.PrintDefaults() os.Exit(1) } var err error if logger, err = flashback.NewLogger(stdout, stderr); err != nil { return err } return nil }
func parseFlags() error { flag.Parse() if style != "stress" && style != "real" { return errors.New("Missing or invalid `style` argument passed to program: " + style) } if opsFilename == "" { return errors.New("Missing required `ops_filename` argument") } if workers <= 0 { return errors.New("The `workers` argument must be a positive number") } if maxOps == 0 { maxOps = math.MaxUint32 } var err error if logger, err = flashback.NewLogger(stdout, stderr); err != nil { return err } return nil }