Skip to content

Instantly share code, notes, and snippets.

@exts
Created April 16, 2018 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exts/eb81ea1d04a964742a85813944e1b602 to your computer and use it in GitHub Desktop.
Save exts/eb81ea1d04a964742a85813944e1b602 to your computer and use it in GitHub Desktop.
proc get[T](settings: SettingsTable, key: string): T =
if settings.hasKey(key):
let val = settings[key]
if (T is string) and val.kind == sString:
return cast[T](val.strVal)
elif (T is seq[string]) and val.kind == sSeqString:
return cast[T](val.seqVal)
raise newException(IndexError, "Invalid Settings Key")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment