mirror of
https://github.com/mudler/luet.git
synced 2025-09-01 15:18:28 +00:00
Enhance output with consistent usage of logger
This commit is contained in:
15
cmd/root.go
15
cmd/root.go
@@ -16,12 +16,12 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
. "github.com/mudler/luet/pkg/logger"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@@ -40,7 +40,7 @@ var RootCmd = &cobra.Command{
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
if err := RootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
Error(err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
@@ -55,12 +55,13 @@ func init() {
|
||||
func initConfig() {
|
||||
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
viper.SetConfigName(".luet") // name of config file (without extension)
|
||||
if cfgFile != "" { // enable ability to specify config file via flag
|
||||
fmt.Println(">>> cfgFile: ", cfgFile)
|
||||
Info(">>> cfgFile: ", cfgFile)
|
||||
viper.SetConfigFile(cfgFile)
|
||||
configDir := path.Dir(cfgFile)
|
||||
if configDir != "." && configDir != dir {
|
||||
@@ -75,9 +76,9 @@ func initConfig() {
|
||||
|
||||
// If a config file is found, read it in.
|
||||
if err := viper.ReadInConfig(); err == nil {
|
||||
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||
Info("Using config file:", viper.ConfigFileUsed())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user