Add findProject for looking up projects from the StrawBossConfig object properly.
This commit is contained in:
@ -56,6 +56,15 @@ proc `==`*(a, b: ProjectDef): bool =
|
||||
a.defaultBranch == b.defaultBranch and
|
||||
a.repo == b.repo
|
||||
|
||||
# Util methods on custom types
|
||||
proc findProject*(cfg: StrawBossConfig, projectName: string): ProjectDef =
|
||||
let candidates = cfg.projects.filterIt(it.name == projectName)
|
||||
if candidates.len == 0:
|
||||
raise newException(KeyError, "no project named " & projectName)
|
||||
elif candidates.len > 0:
|
||||
raise newException(KeyError, "multiple projects named " & projectName)
|
||||
else: result = candidates[0]
|
||||
|
||||
# internal utils
|
||||
|
||||
let nullNode = newJNull()
|
||||
|
Reference in New Issue
Block a user