Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barcharcraz/aed8d1dad1d741a37d3df41071b2cc18 to your computer and use it in GitHub Desktop.
Save barcharcraz/aed8d1dad1d741a37d3df41071b2cc18 to your computer and use it in GitHub Desktop.
macro `.`*(pkg: PkgInstall, field: untyped): untyped =
## ^ This makes PkgInstall types act like concatinations
## of the Pkg, PkgVer and PkgLayout types
var subfields = pkg.getType.last
expectKind(subfields, nnkRecList)
for elm in subfields:
var fields = elm.getType.last
expectKind(fields, nnkRecList)
var real_field = findChild(fields, eqIdent(it, $field))
if real_field != nil:
result = newDotExpr(pkg, elm).newDotExpr real_field
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment