From 37b8c46b3b5ff0ff5dca2c5438f953f56efe41d8 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Fri, 8 Nov 2013 11:36:58 +0100 Subject: [PATCH] Adds support for optional web field. This change makes nimrod-code/packages#31 useful. --- packageinfo.nim | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packageinfo.nim b/packageinfo.nim index bdb6c07..d482086 100644 --- a/packageinfo.nim +++ b/packageinfo.nim @@ -22,14 +22,17 @@ type backend*: string TPackage* = object + # Required fields in a package. name*: string - version*: string + url*: string # Download location. license*: string - url*: string - dvcsTag*: string downloadMethod*: string - tags*: seq[string] description*: string + tags*: seq[string] # Even if empty, always a valid non nil seq. \ + # From here on, optional fields set to the emtpy string if not available. + version*: string + dvcsTag*: string + web*: string # Info url for humans. proc initPackageInfo(): TPackageInfo = result.mypath = "" @@ -168,6 +171,7 @@ proc getPackage*(pkg: string, packagesPath: string, resPkg: var TPackage): bool for t in p["tags"]: resPkg.tags.add(t.str) resPkg.description = p.requiredField("description") + resPkg.web = p.optionalField("web") return true return false @@ -186,6 +190,7 @@ proc getPackageList*(packagesPath: string): seq[TPackage] = for t in p["tags"]: pkg.tags.add(t.str) pkg.description = p.requiredField("description") + pkg.web = p.optionalField("web") result.add(pkg) proc findBabelFile*(dir: string): string = @@ -245,3 +250,5 @@ proc echoPackage*(pkg: TPackage) = echo(" tags: " & pkg.tags.join(", ")) echo(" description: " & pkg.description) echo(" license: " & pkg.license) + if pkg.web.len > 0: + echo(" website: " & pkg.web)