Skip to content

Commit

Permalink
chore: Update cobrax version
Browse files Browse the repository at this point in the history
  • Loading branch information
haijima committed Dec 29, 2023
1 parent 1de7fa3 commit dfd0088
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"log/slog"
"strings"

"github.com/fatih/color"
"github.com/haijima/cobrax"
Expand Down Expand Up @@ -52,19 +53,20 @@ func setup(v *viper.Viper) func(cmd *cobra.Command, args []string) error {
l := Logger(v)
slog.SetDefault(l)
cobrax.SetLogger(l)

// Read config file
cfg, err := cmd.Flags().GetString("config")
if err != nil {
if err := cobrax.NewConfigBinder(cmd).Bind(v); err != nil {
return err
}
if err := cobrax.ReadConfigFile(v, cfg, true, cmd.Name()); err != nil {
if err := cobrax.OverrideBySubConfig(v, strings.ToLower(cmd.Name())); err != nil {
return err
}
// Bind flags (flags of the command to be executed)
if err := v.BindPFlags(cmd.Flags()); err != nil {
return err
}
// Print config values
slog.Info("bind flags and config values")
slog.Debug(cobrax.DebugViper(v))
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/expr-lang/expr v1.15.7
github.com/fatih/color v1.16.0
github.com/haijima/cobrax v0.1.0
github.com/haijima/cobrax v0.1.1
github.com/haijima/gini v0.0.2
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-colorable v0.1.13
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/haijima/cobrax v0.1.0 h1:9VIuM+iyymxUnFBPTCXyEPnFsDg0qMpJDhmIgNg63QY=
github.com/haijima/cobrax v0.1.0/go.mod h1:ocESFWrHTaR0NjrIS5Q1D/sJajOgxcVEnXVmOaiBmUI=
github.com/haijima/cobrax v0.1.1 h1:lVjzWX0WAQoEJY+bq5gcA/f/lg15xUO6JMIbVLqb8c0=
github.com/haijima/cobrax v0.1.1/go.mod h1:ocESFWrHTaR0NjrIS5Q1D/sJajOgxcVEnXVmOaiBmUI=
github.com/haijima/gini v0.0.2 h1:Qdtm7MAEXTBsgZIxdRedHcx1GV1VdE6YIV+73Ck3PzA=
github.com/haijima/gini v0.0.2/go.mod h1:/PPE6lWMY7oJ3ZilOc0vyDhJ/q07QAPInGWJFOTxEGY=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
Expand Down

0 comments on commit dfd0088

Please sign in to comment.