From ef3493e72b79551428337c81afbbf520a2fa6323 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Sat, 27 Jul 2024 04:27:19 -0500 Subject: [PATCH] feat(config): Use logger for deprecated flag warnings --- internal/config/flags.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/config/flags.go b/internal/config/flags.go index 8f6a0e7..498926b 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -1,6 +1,9 @@ package config import ( + "bytes" + + "github.com/rs/zerolog/log" "github.com/spf13/cobra" ) @@ -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 }