func NewSplitStrategy(logger logutil.Logger, argsStr string) (*SplitStrategy, error) { var args []string if argsStr != "" { args = strings.Split(argsStr, " ") } flagSet := flag.NewFlagSet("strategy", flag.ContinueOnError) flagSet.SetOutput(logutil.NewLoggerWriter(logger)) flagSet.Usage = func() { logger.Printf("Strategy flag has the following options:\n") flagSet.PrintDefaults() } populateBlpCheckpoint := flagSet.Bool("populate_blp_checkpoint", false, "populates the blp checkpoint table") dontStartBinlogPlayer := flagSet.Bool("dont_start_binlog_player", false, "do not start the binlog player after restore is complete") skipSetSourceShards := flagSet.Bool("skip_set_source_shards", false, "do not set the SourceShar field on destination shards") if err := flagSet.Parse(args); err != nil { return nil, fmt.Errorf("cannot parse strategy: %v", err) } if flagSet.NArg() > 0 { return nil, fmt.Errorf("strategy doesn't have positional arguments") } return &SplitStrategy{ PopulateBlpCheckpoint: *populateBlpCheckpoint, DontStartBinlogPlayer: *dontStartBinlogPlayer, SkipSetSourceShards: *skipSetSourceShards, }, nil }
func printUpdatedThrottlers(logger logutil.Logger, server string, names []string) { table := tablewriter.NewWriter(loggerWriter{logger}) table.SetAutoFormatHeaders(false) table.SetHeader([]string{"Name"}) for _, name := range names { table.Append([]string{name}) } table.Render() logger.Printf("%d active throttler(s) on server '%v' were updated.\n", len(names), server) }
// PrintAllCommands prints a help text for all registered commands to the given Logger. func PrintAllCommands(logger logutil.Logger) { for _, group := range commands { if group.Name == "Debugging" { continue } logger.Printf("%v: %v\n", group.Name, group.Description) for _, cmd := range group.Commands { logger.Printf(" %v %v\n", cmd.Name, cmd.Params) } logger.Printf("\n") } }