diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-08-16 23:27:52 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-08-16 23:27:52 +0530 |
commit | c413effd06e43abd197735915d136124324e24b1 (patch) | |
tree | cafbfad6a4f96bf81414d392bd576556ecddfc92 /cmd | |
parent | 10657c98d38f0db4f58c853f125301ee8af8542f (diff) |
properly reading the config file contents
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/root.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/cmd/root.go b/cmd/root.go index 7e23984..1b956cf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,8 +27,15 @@ import ( ) var ( - queryOnlyMode , mangaMode bool + queryOnlyMode, mangaMode bool entryId int + authConfig, defConfig map[string]interface{} + + // config vars + /* TODO: load config vars here + * then set config file's values or default values + * conditionally after loading the config file + */ ) var rootCmd = &cobra.Command{ @@ -50,15 +57,14 @@ func init() { // error if config file found but has errors if _, ok := err.(viper.ConfigFileNotFoundError); !ok { fmt.Println("Error while reading macli config file:", err) + fmt.Println("Exiting... Please check the macli config file.") os.Exit(1) } } - authConfig := viper.Get("auth").(map[string]interface{}) - defConfig := viper.Get("defaults").(map[string]interface{}) - - fmt.Println("Config File Contents:", authConfig["token"], defConfig["prompt_length"]) - os.Exit(0) + // load config file contents + authConfig = viper.Get("auth").(map[string]interface{}) + defConfig = viper.Get("defaults").(map[string]interface{}) } func Execute() { |