mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 10:24:44 +00:00
Update parsecfg.nim (#15513)
* Update parsecfg.nim Returns the specified default value if the specified key value does not exist. * Update lib/pure/parsecfg.nim Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com> * Update lib/pure/parsecfg.nim Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com> * Update lib/pure/parsecfg.nim Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com> Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
This commit is contained in:
@@ -560,15 +560,16 @@ proc writeConfig*(dict: Config, filename: string) =
|
||||
let fileStream = newFileStream(file)
|
||||
dict.writeConfig(fileStream)
|
||||
|
||||
proc getSectionValue*(dict: Config, section, key: string): string =
|
||||
## Gets the Key value of the specified Section, returns an empty string if the key does not exist.
|
||||
proc getSectionValue*(dict: Config, section, key: string, defaultVal = ""): string =
|
||||
## Gets the key value of the specified Section.
|
||||
## Returns the specified default value if the specified key does not exist.
|
||||
if dict.hasKey(section):
|
||||
if dict[section].hasKey(key):
|
||||
result = dict[section][key]
|
||||
else:
|
||||
result = ""
|
||||
result = defaultVal
|
||||
else:
|
||||
result = ""
|
||||
result = defaultVal
|
||||
|
||||
proc setSectionKey*(dict: var Config, section, key, value: string) =
|
||||
## Sets the Key value of the specified Section.
|
||||
|
||||
Reference in New Issue
Block a user