mirror of
https://github.com/status-im/nim-confutils.git
synced 2025-01-22 01:50:35 +00:00
fix the handling of default values for enums
This commit is contained in:
parent
311cf156b8
commit
24416148f6
@ -183,7 +183,10 @@ proc load*(Configuration: type,
|
||||
when `recordField` is enum:
|
||||
# TODO: For some reason, the normal `setField` rejects enum fields
|
||||
# when they are used as case discriminators. File this as a bug.
|
||||
`recordField` = parseEnum[type(`recordField`)](string(val))
|
||||
if len(val) > 0:
|
||||
`recordField` = parseEnum[type(`recordField`)](string(val))
|
||||
else:
|
||||
`recordField` = `defaultValue`
|
||||
return true
|
||||
else:
|
||||
return setField(`recordField`, val, `defaultValue`)
|
||||
@ -246,7 +249,7 @@ proc load*(Configuration: type,
|
||||
proc fail(msg: string) =
|
||||
if quitOnFailure:
|
||||
stderr.writeLine(msg)
|
||||
stderr.writeLine("Try '{1} --help' for more information" % appName)
|
||||
stderr.writeLine("Try '$1 --help' for more information" % appName)
|
||||
quit 1
|
||||
else:
|
||||
raise newException(ConfigurationError, msg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user