Skip to content

Commit

Permalink
cmd: fix --log-level help message and viper bind
Browse files Browse the repository at this point in the history
Add the missing descriptive help message to the `--log-level` flag and
fix the Viper config bind.

Signed-off-by: Luiz Aoqui <luizaoqui@loopholelabs.io>
  • Loading branch information
lgfa29 committed Nov 7, 2024
1 parent 338db99 commit f8b53d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ func (c *Command[T]) runCmd(ctx context.Context, commandType Type) error {
}

c.logLevel = types.InfoLevel
c.command.PersistentFlags().VarP(&c.logLevel, "log-level", "", "")
if err = viper.BindPFlag("log-level", c.command.PersistentFlags().Lookup("debug")); err != nil {
c.command.PersistentFlags().VarP(&c.logLevel, "log-level", "", "Specifies the level of log verbosity. Possible values: [fatal, error, warn, info, debug, trace]")
if err = viper.BindPFlag("log-level", c.command.PersistentFlags().Lookup("log-level")); err != nil {
return err
}
_ = c.command.RegisterFlagCompletionFunc("log-level", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
Expand Down

0 comments on commit f8b53d1

Please sign in to comment.