Update Makefile and add version flag

This commit is contained in:
2025-12-21 16:34:57 +02:00
parent eef69eed9a
commit 4e296b5104
4 changed files with 40 additions and 29 deletions
+2 -2
View File
@@ -28,8 +28,8 @@ func readConfig() {
// Find valid config directory
if _, err := os.Stat(path.Join(userConfigDir, "stormfetch/config.yaml")); err == nil {
configPath = path.Join(userConfigDir, "stormfetch/config.yaml")
} else if _, err := os.Stat(path.Join(systemConfigDir, "stormfetch/config.yaml")); err == nil {
configPath = path.Join(systemConfigDir, "stormfetch/config.yaml")
} else if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/config.yaml")); err == nil {
configPath = path.Join(SystemConfigDir, "stormfetch/config.yaml")
} else {
log.Fatalf("Config file not found: %s", err.Error())
}
+10 -2
View File
@@ -9,9 +9,11 @@ import (
)
// Build-time variables
var systemConfigDir = "/etc/"
var StormfetchVersion = "dev"
var SystemConfigDir = "/etc/"
// Flag variables
var ShowVersion = false
var ShowModuleTimeTaken = false
var configPath = ""
@@ -24,13 +26,19 @@ func main() {
}
func parseFlags() {
flag.BoolVar(&ShowVersion, "version", false, "Show Stormfetch version")
flag.BoolVar(&ShowModuleTimeTaken, "time-taken", false, "Show time taken to execute each module")
flag.StringVar(&config.Ascii, "ascii", config.Ascii, "Set distro ascii")
flag.StringVar(&config.DistroName, "distro-name", config.DistroName, "Set distro name")
flag.BoolVar(&ShowModuleTimeTaken, "time-taken", false, "Show time taken to execute each module")
flag.Parse()
}
func run() {
if ShowVersion {
fmt.Printf("Stormfetch version %s\n", StormfetchVersion)
return
}
// Fetch ascii art and remove header
asciiArt := GetDistroAsciiArt()
asciiArtHeader := ""
+4 -4
View File
@@ -73,8 +73,8 @@ func GetDistroAsciiArt() string {
}
userConfDir, err := os.UserConfigDir()
if err != nil {
if _, err := os.Stat(path.Join(systemConfigDir, "stormfetch/ascii/", id)); err == nil {
bytes, err := os.ReadFile(path.Join(systemConfigDir, "stormfetch/ascii/", id))
if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/ascii/", id)); err == nil {
bytes, err := os.ReadFile(path.Join(SystemConfigDir, "stormfetch/ascii/", id))
if err != nil {
return defaultAscii
}
@@ -89,8 +89,8 @@ func GetDistroAsciiArt() string {
return defaultAscii
}
return string(bytes)
} else if _, err := os.Stat(path.Join(systemConfigDir, "stormfetch/ascii/", id)); err == nil {
bytes, err := os.ReadFile(path.Join(systemConfigDir, "stormfetch/ascii/", id))
} else if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/ascii/", id)); err == nil {
bytes, err := os.ReadFile(path.Join(SystemConfigDir, "stormfetch/ascii/", id))
if err != nil {
return defaultAscii
}