Add version and build date

This commit is contained in:
aditya-K2
2023-05-24 02:48:54 +05:30
parent 79f4ae5a75
commit 5997ea30d3
2 changed files with 12 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package config
import (
"fmt"
"os"
"path/filepath"
@@ -15,6 +16,8 @@ var (
UserConfigPath = filepath.Join(configDir, "gspt")
Config = NewConfigS()
OnConfigChange func()
Version = "unknown"
BuildDate = "unknown"
)
type ConfigS struct {
@@ -43,6 +46,10 @@ func NewConfigS() *ConfigS {
func ReadConfig() {
parseFlags()
if Flags.Version {
fmt.Printf("gspt %s \nBuild Date: %s\n", Version, BuildDate)
}
// If config path is provided through command-line use that
if Flags.ConfigPath != "" {
UserConfigPath = Flags.ConfigPath

View File

@@ -10,6 +10,7 @@ var (
type Flag struct {
ConfigPath string
Version bool
HideImage bool
RoundedCorners bool
UseIcons bool
@@ -20,6 +21,10 @@ func parseFlags() {
"Specify The Directory to check for config.yml file.")
flag.BoolVar(&Flags.HideImage, "hide-image", Config.HideImage,
"Do not display the cover art image.")
flag.BoolVar(&Flags.Version, "v", false,
"Do not display the cover art image.")
flag.BoolVar(&Flags.Version, "version", false,
"Do not display the cover art image.")
flag.BoolVar(&Flags.RoundedCorners, "rounded-corners", Config.RoundedCorners,
"Enable Rounded Corners")
flag.BoolVar(&Flags.UseIcons, "icons", Config.UseIcons,