Skip to content

Commit

Permalink
Fix options reading in history purge command. (#5243)
Browse files Browse the repository at this point in the history
The added code makes it easier to read CLI options. It's probably a
good idea to refactor that in a function wrapper.
  • Loading branch information
blkt authored Jan 3, 2025
1 parent 4c5eefb commit de9b376
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/server/app/history_purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ var historyPurgeCmd = &cobra.Command{
}

func historyPurgeCommand(cmd *cobra.Command, _ []string) error {
batchSize := viper.GetUint("batch-size")
dryRun := viper.GetBool("dry-run")

// TODO: This statement and the following could be refactored
// in a function similar to `GRPCClientWrapRunE`
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return fmt.Errorf("error binding flags: %s", err)
}
cfg, err := config.ReadConfigFromViper[serverconfig.Config](viper.GetViper())
if err != nil {
cliErrorf(cmd, "unable to read config: %s", err)
}

batchSize := viper.GetUint("batch-size")
dryRun := viper.GetBool("dry-run")

ctx := serverconfig.LoggerFromConfigFlags(cfg.LoggingConfig).WithContext(context.Background())

// instantiate `db.Store` so we can run queries
Expand Down

0 comments on commit de9b376

Please sign in to comment.