Skip to content

Commit

Permalink
Fix order of loading config directory
Browse files Browse the repository at this point in the history
  • Loading branch information
justincampbell committed Jan 18, 2021
1 parent 5cddc6f commit c40c0bd
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ var (
)

func init() {
var err error

client, err = openpomodoro.NewClient(directoryFlag)
if err != nil {
log.Fatalf("Could not create client: %v", err)
}

settings, err = client.Settings()
if err != nil {
log.Fatalf("Could not retrieve settings: %v", err)
}

cobra.OnInitialize(initConfig)

RootCmd.PersistentFlags().StringVarP(
Expand All @@ -53,6 +41,20 @@ func init() {
RootCmd.PersistentFlags().BoolVarP(
&waitFlag, "wait", "w", false,
"wait for the Pomodoro to end before exiting")

viper.AutomaticEnv()

var err error

client, err = openpomodoro.NewClient(directoryFlag)
if err != nil {
log.Fatalf("Could not create client: %v", err)
}

settings, err = client.Settings()
if err != nil {
log.Fatalf("Could not retrieve settings: %v", err)
}
}

func initConfig() {
Expand Down

0 comments on commit c40c0bd

Please sign in to comment.