norgbackup/norg/utils/version.nim

22 lines
663 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
if new[0] > cur[0]: return true
elif new[1] > cur[1]: return true
elif new[2] > cur[2]: return true
return false