diff --git a/build/packaging/suseconnect-ng.changes b/build/packaging/suseconnect-ng.changes index f570a05b..be36868c 100644 --- a/build/packaging/suseconnect-ng.changes +++ b/build/packaging/suseconnect-ng.changes @@ -1,12 +1,8 @@ ------------------------------------------------------------------- -Wed Aug 28 20:31:47 UTC 2024 - Charu Jain - -- Integrating uptime-tracker - ------------------------------------------------------------------- Fri Sep 13 15:56:05 UTC 2024 - Miquel Sabate Sola - IN PROGRESS: 1.13 + - Integrating uptime-tracker ------------------------------------------------------------------- Fri Sep 13 14:11:22 UTC 2024 - Miquel Sabate Sola diff --git a/cmd/suse-uptime-tracker/uptime_tracker.go b/cmd/suse-uptime-tracker/uptime_tracker.go index e8b35c89..be8168ab 100644 --- a/cmd/suse-uptime-tracker/uptime_tracker.go +++ b/cmd/suse-uptime-tracker/uptime_tracker.go @@ -26,7 +26,6 @@ const ( daysBeforePurge = 90 // purge all the records after this many days ) -// getShortenedVersion returns the short program version func getShortenedVersion() string { return strings.Split(strings.TrimSpace(version), "~")[0] } @@ -39,6 +38,24 @@ func exitOnError(err error) { os.Exit(1) } +func displayUptimeVersion() { + var ( + version bool + ) + + flag.Usage = func() { + fmt.Print(uptimeTrackerUsageText) + } + + flag.BoolVar(&version, "version", false, "") + + flag.Parse() + if version { + fmt.Println(getShortenedVersion()) + os.Exit(0) + } +} + func readUptimeLogFile(uptimeLogsFilePath string) (map[string]string, error) { uptimeLogsFile, err := os.Open(uptimeLogsFilePath) if err != nil { @@ -124,22 +141,7 @@ func writeUptimeLogsFile(uptimeLogsFilePath string, uptimeLogs map[string]string } func main() { - var ( - version bool - ) - - flag.Usage = func() { - fmt.Print(uptimeTrackerUsageText) - } - - flag.BoolVar(&version, "version", false, "") - - flag.Parse() - if version { - fmt.Println(getShortenedVersion()) - os.Exit(0) - } - + displayUptimeVersion() uptimeLogs, err := readUptimeLogFile(uptimeCheckLogsFilePath) exitOnError(err) uptimeLogs, err = purgeOldUptimeLog(uptimeLogs)