Skip to content

Commit

Permalink
Merge pull request markusressel#207 from jfroy/uisetup
Browse files Browse the repository at this point in the history
Call `setupUi` from `cobra.OnInitialize` so it applies to all commands
  • Loading branch information
markusressel authored Feb 26, 2023
2 parents 85eec79 + 2fda7a5 commit 7d66fc9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cmd

import (
"fmt"
"os"

"github.com/markusressel/fan2go/cmd/config"
"github.com/markusressel/fan2go/cmd/curve"
"github.com/markusressel/fan2go/cmd/fan"
Expand All @@ -12,7 +14,6 @@ import (
"github.com/markusressel/fan2go/internal/ui"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"os"
)

// rootCmd represents the base command when called without any subcommands
Expand All @@ -23,7 +24,6 @@ var rootCmd = &cobra.Command{
on your computer based on temperature sensors.`,
// this is the default command to run when no subcommand is specified
Run: func(cmd *cobra.Command, args []string) {
setupUi()
printHeader()

configPath := configuration.DetectAndReadConfigFile()
Expand Down Expand Up @@ -80,6 +80,7 @@ func printHeader() {
func Execute() {
cobra.OnInitialize(func() {
configuration.InitConfig(global.CfgFile)
setupUi()
})

if err := rootCmd.Execute(); err != nil {
Expand Down

0 comments on commit 7d66fc9

Please sign in to comment.