21 lines
612 B
Nim
21 lines
612 B
Nim
|
import parsetoml
|
||
|
|
||
|
import ../model/config_type
|
||
|
export config_type
|
||
|
|
||
|
proc parseConfigFile*(file: string): NorgConfig =
|
||
|
norg_config = newNorgConfig()
|
||
|
let in_conf = parsetoml.parseFile(file)
|
||
|
for dir in in_conf{"source_dirs"}.getElems():
|
||
|
norg_config.source_dirs.add(dir.getStr())
|
||
|
for r in in_conf{"repositories"}.getElems():
|
||
|
let rtable = r.getTable()
|
||
|
var repo = Repository()
|
||
|
repo.path = rtable["path"].getStr()
|
||
|
repo.label = rtable["label"].getStr()
|
||
|
norg_config.repositories.add(repo)
|
||
|
norg_config.setEncryptionPassword(in_conf{"encryption_password"}.getStr(""))
|
||
|
return norg_config
|
||
|
|
||
|
|