Skip to content

Commit

Permalink
feat(config): Use logger for deprecated flag warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jul 27, 2024
1 parent 093235e commit ef3493e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/config/flags.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package config

import (
"bytes"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -53,4 +56,14 @@ func (c *Config) RegisterFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&c.LogFormat, LogFormatFlag, c.LogFormat, "Log format (auto, color, plain, json)")

cmd.Flags().StringVar(&c.Completion, CompletionFlag, c.Completion, "Output command-line completion code for the specified shell. Can be 'bash', 'zsh', 'fish', or 'powershell'.")

initLog(cmd)
cmd.Flags().SetOutput(DeprecatedWriter{})
}

type DeprecatedWriter struct{}

func (d DeprecatedWriter) Write(b []byte) (int, error) {
log.Warn().Msg(string(bytes.TrimSpace(b)))
return len(b), nil
}

0 comments on commit ef3493e

Please sign in to comment.