Load config from file with defaults

This commit is contained in:
Dan Jones 2024-02-04 18:19:19 -06:00
commit 40f9518611
8 changed files with 127 additions and 2 deletions

View file

@ -19,6 +19,7 @@ package cmd
import (
"os"
"codeberg.org/danjones000/my-log/config"
"github.com/spf13/cobra"
)
@ -50,11 +51,11 @@ func init() {
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.my-log.yaml)")
rootCmd.PersistentFlags().StringVarP(&config.ConfigPath, "config", "c", config.ConfigPath, "config file")
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
// initConfig reads in config file and ENV variables if set.