mirror of
https://github.com/status-im/nim-confutils.git
synced 2025-02-15 13:37:04 +00:00
- The config files processing was not taking into account the `name` pragma of the configuration object fields. - The required fields were not searched within config files before reporting an error that they are missing. - Fields with the same names were not supported in different case branches - The loaded config file path can now depend on the configuration supplied through the command-line.
21 lines
633 B
Nim
21 lines
633 B
Nim
import
|
|
stew/shims/net,
|
|
toml_serialization, toml_serialization/lexer
|
|
|
|
export
|
|
net, toml_serialization
|
|
|
|
proc readValue*(r: var TomlReader, val: var ValidIpAddress)
|
|
{.raises: [SerializationError, IOError, Defect].} =
|
|
val = try: ValidIpAddress.init(r.readValue(string))
|
|
except ValueError as err:
|
|
r.lex.raiseUnexpectedValue("IP address")
|
|
|
|
proc readValue*(r: var TomlReader, val: var Port)
|
|
{.raises: [SerializationError, IOError, Defect].} =
|
|
let port = try: r.readValue(uint16)
|
|
except ValueError:
|
|
r.lex.raiseUnexpectedValue("Port")
|
|
|
|
val = Port port
|