norgbackup/norg/utils/version.nim

21 lines
630 B
Nim
Raw Normal View History

import parsecfg
import streams
2025-01-02 14:09:59 +01:00
import strutils
import sequtils
proc getVersion*(): string =
let nimble = staticRead("../../norg.nimble")
var p: Config = loadConfig(newStringStream(nimble))
let vers = p.getSectionValue("","version")
echo "Compiling version: v", vers
return "v" & vers
2025-01-02 14:09:59 +01:00
proc newerThan*(a,b: string): bool =
let new = a[1..^1].split(".").map(proc(s: string): int = s.parseInt())
let cur = b[1..^1].split(".").map(proc(s: string): int = s.parseInt())
echo "Latest Version: " & a
echo "Current Version: " & b
2025-01-02 18:32:03 +01:00
for i in countup(0, len(cur) - 1):
if new[i] > cur[i]: return true
2025-01-02 14:09:59 +01:00
return false