diff --git a/Makefile b/Makefile index 4c4852d..afea018 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ REPO := aditya-K2/gspt GC := go VERBOSE = GOFLAGS := -buildmode=pie -trimpath -mod=readonly -modcacherw -LDFLAGS := -ldflags="-X github.com/${REPO}/config.Version=${VERSION} -X github.com/${REPO}/config.BuildDate=${DATE}" +LDFLAGS := -ldflags="-X github.com/${REPO}/config.version=${VERSION} -X github.com/${REPO}/config.buildDate=${DATE}" BUILD := ${GC} build ${GOFLAGS} ${LDFLAGS} ${VERBOSE} .PHONY: gspt install linux-arm64 linux-amd64 darwin-amd64 darwin-arm64 windows-amd64 diff --git a/config/config.go b/config/config.go index 102676e..d1943a6 100644 --- a/config/config.go +++ b/config/config.go @@ -13,14 +13,14 @@ import ( var ( configDir, configErr = os.UserConfigDir() userCacheDir, cacheErr = os.UserCacheDir() - UserConfigPath = filepath.Join(configDir, "gspt") - Config = NewConfigS() + userConfigPath = filepath.Join(configDir, "gspt") + Config = newConfigS() OnConfigChange func() - Version = "unknown" - BuildDate = "unknown" + version = "unknown" + buildDate = "unknown" ) -type ConfigS struct { +type configS struct { CacheDir string `yaml:"cache_dir" mapstructure:"cache_dir"` RedrawInterval int `yaml:"redraw_interval" mapstructure:"redraw_interval"` Colors *Colors `mapstructure:"colors"` @@ -34,8 +34,8 @@ type ConfigS struct { UseIcons bool `yaml:"use_icons" mapstructure:"use_icons"` } -func NewConfigS() *ConfigS { - return &ConfigS{ +func newConfigS() *configS { + return &configS{ CacheDir: utils.CheckDirectoryFmt(userCacheDir), RedrawInterval: 500, Colors: NewColors(), @@ -47,13 +47,13 @@ func ReadConfig() { parseFlags() if Flags.Version { - fmt.Printf("gspt: %s \nBuild Date: %s\n", Version, BuildDate) + fmt.Printf("gspt: %s \nBuild Date: %s\n", version, buildDate) os.Exit(0) } // If config path is provided through command-line use that if Flags.ConfigPath != "" { - UserConfigPath = Flags.ConfigPath + userConfigPath = Flags.ConfigPath } if configErr != nil { @@ -67,7 +67,7 @@ func ReadConfig() { } viper.SetConfigName("config") - viper.AddConfigPath(utils.ExpandHomeDir(UserConfigPath)) + viper.AddConfigPath(utils.ExpandHomeDir(userConfigPath)) if err := viper.ReadInConfig(); err != nil { utils.Print("RED", "Could Not Read Config file.\n") diff --git a/config/flags.go b/config/flags.go index 1f5daef..81c6d7c 100644 --- a/config/flags.go +++ b/config/flags.go @@ -17,7 +17,7 @@ type Flag struct { } func parseFlags() { - flag.StringVar(&Flags.ConfigPath, "c", UserConfigPath, + flag.StringVar(&Flags.ConfigPath, "c", userConfigPath, "Specify The Directory to check for config.yml file.") flag.BoolVar(&Flags.HideImage, "hide-image", Config.HideImage, "Do not display the cover art image.")