2024-08-16 17:40:24 +02:00
|
|
|
import parsetoml
|
|
|
|
|
|
|
|
import ../model/config_type
|
2024-08-17 19:00:30 +02:00
|
|
|
import notifier_config
|
2024-08-16 17:40:24 +02:00
|
|
|
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(""))
|
2024-08-17 19:00:30 +02:00
|
|
|
norg_config.notifiers = parseNotifiers(in_conf)
|
2024-08-16 17:40:24 +02:00
|
|
|
return norg_config
|
|
|
|
|
|
|
|
|