From adffba663dbe8daebe311dc8f3ae5d40109cb2dd Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 17 Aug 2022 22:33:40 +0530 Subject: reading config file's defaults while searching --- cmd/root.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'cmd/root.go') diff --git a/cmd/root.go b/cmd/root.go index 1b956cf..02d27a1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -29,22 +29,24 @@ import ( var ( 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 - */ + // auth + saveClientId string = "yes" + // searching + promptLength, searchLength, searchOffset int = 5, 10, 0 + searchNsfw bool = false + // lists + listOffset, listLength int = 0, 15 + listIncludeNsfw bool = false ) var rootCmd = &cobra.Command{ - Use: "macli", + Use: "macli", Short: "macli - Unofficial CLI-Based MyAnimeList Client.", Long: "macli is an unofficial MyAnimeList Client for use inside the terminal.", } -func init() { +func Execute() { viper.SetConfigName("macli") viper.SetConfigType("yaml") viper.AddConfigPath(".") @@ -62,12 +64,6 @@ func init() { } } - // load config file contents - authConfig = viper.Get("auth").(map[string]interface{}) - defConfig = viper.Get("defaults").(map[string]interface{}) -} - -func Execute() { err := rootCmd.Execute() if err != nil { os.Exit(1) -- cgit v1.2.3