Adds support for optional web field.
This change makes nimrod-code/packages#31 useful.
This commit is contained in:
parent
37ad951b6e
commit
37b8c46b3b
1 changed files with 11 additions and 4 deletions
|
|
@ -22,14 +22,17 @@ type
|
||||||
backend*: string
|
backend*: string
|
||||||
|
|
||||||
TPackage* = object
|
TPackage* = object
|
||||||
|
# Required fields in a package.
|
||||||
name*: string
|
name*: string
|
||||||
version*: string
|
url*: string # Download location.
|
||||||
license*: string
|
license*: string
|
||||||
url*: string
|
|
||||||
dvcsTag*: string
|
|
||||||
downloadMethod*: string
|
downloadMethod*: string
|
||||||
tags*: seq[string]
|
|
||||||
description*: 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 =
|
proc initPackageInfo(): TPackageInfo =
|
||||||
result.mypath = ""
|
result.mypath = ""
|
||||||
|
|
@ -168,6 +171,7 @@ proc getPackage*(pkg: string, packagesPath: string, resPkg: var TPackage): bool
|
||||||
for t in p["tags"]:
|
for t in p["tags"]:
|
||||||
resPkg.tags.add(t.str)
|
resPkg.tags.add(t.str)
|
||||||
resPkg.description = p.requiredField("description")
|
resPkg.description = p.requiredField("description")
|
||||||
|
resPkg.web = p.optionalField("web")
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
@ -186,6 +190,7 @@ proc getPackageList*(packagesPath: string): seq[TPackage] =
|
||||||
for t in p["tags"]:
|
for t in p["tags"]:
|
||||||
pkg.tags.add(t.str)
|
pkg.tags.add(t.str)
|
||||||
pkg.description = p.requiredField("description")
|
pkg.description = p.requiredField("description")
|
||||||
|
pkg.web = p.optionalField("web")
|
||||||
result.add(pkg)
|
result.add(pkg)
|
||||||
|
|
||||||
proc findBabelFile*(dir: string): string =
|
proc findBabelFile*(dir: string): string =
|
||||||
|
|
@ -245,3 +250,5 @@ proc echoPackage*(pkg: TPackage) =
|
||||||
echo(" tags: " & pkg.tags.join(", "))
|
echo(" tags: " & pkg.tags.join(", "))
|
||||||
echo(" description: " & pkg.description)
|
echo(" description: " & pkg.description)
|
||||||
echo(" license: " & pkg.license)
|
echo(" license: " & pkg.license)
|
||||||
|
if pkg.web.len > 0:
|
||||||
|
echo(" website: " & pkg.web)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue