Skip to content

Commit

Permalink
fix: apply verbose flag when all config has been loaded
Browse files Browse the repository at this point in the history
verbose flag was loaded outside the configuration load, so
whatever you did put in the config file was not applied later.
  • Loading branch information
beltrachi committed Oct 14, 2023
1 parent f558077 commit f01d52e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions config/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/viper"
"fmt"
"os"
"log"
"github.com/apex/log"
)

const (
Expand All @@ -28,6 +28,10 @@ func CommitConfig() root_runner.RunnerOptions {
os.Exit(1)
}

if viper.GetBool("verbose") {
log.SetLevel(log.DebugLevel)
}

if viper.IsSet("commits.strict") {
strict = viper.GetBool("commits.strict")
}
Expand Down Expand Up @@ -72,7 +76,7 @@ func LoadConfig() error {
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
// Config file not found; ignore error if desired
log.Println("config file not found, using defaults")
log.Warn("config file not found, using defaults")
} else {
// Config file was found but another error was produced
return err
Expand Down
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ var commit string
var date string

func runRoot(cmd *cobra.Command, args []string) error {
if viper.GetBool("verbose") {
log.SetLevel(log.DebugLevel)
}

runner := root_runner.New()

commitConfig := config.CommitConfig()
Expand Down

0 comments on commit f01d52e

Please sign in to comment.