This module contains basic configure facilities like retrieving, setting environment variables and so on.
Example:
import os, tables, streams let prefix = "PROLOGUE_" # only work in application scope delEnv("PROLOGUE") putPrologueEnv("debug", "true", prefix) putPrologueEnv("port", "8080", prefix) putPrologueEnv("appName", "Prologue", prefix) putPrologueEnv("staticDir", "static", prefix) discard getAllPrologueEnv(prefix) let config = newStringStream("""[Prologue] debug=true port=8080 appName=Prologue staticDir=static """) let tab = loadConfig(config)["Prologue"] doAssert tab["appName"] == "Prologue" doAssert tab["staticDir"] == "static" doAssert tab["debug"] == "true" doAssert tab["port"] == "8080"
Procs
proc getPrologueEnv(): string {...}{.raises: [], tags: [ReadEnvEffect].}
- Gets PROLOGUE env variables. Source Edit
proc putPrologueEnv(key, val: string; prefix: string) {...}{.inline, raises: [OSError], tags: [WriteEnvEffect].}
- Puts (key, val) pairs with prefix to environment variables. Source Edit
proc getPrologueEnv(key: string; prefix: string; default = ""): string {...}{.inline, raises: [], tags: [ReadEnvEffect].}
- Gets (key, val) pairs with prefix from environment variables. If key can't be found, default will be returned. Source Edit
proc getAllPrologueEnv(prefix: string): OrderedTableRef[string, string] {...}{. inline, raises: [], tags: [ReadEnvEffect].}
- Gets all (key, val) pairs with prefix from environment variables. Source Edit
proc existsPrologueEnv(key: string; prefix: string): bool {...}{.inline, raises: [], tags: [ReadEnvEffect].}
- Source Edit
proc delPrologueEnv(key: string; prefix: string) {...}{.inline, raises: [OSError], tags: [WriteEnvEffect].}
- Source Edit
proc loadPrologueEnv(filename: string): Env {...}{. raises: [IOError, OSError, Exception, ValueError, EnvWrongFormatError], tags: [ReadIOEffect, RootEffect, WriteIOEffect].}
- Source Edit
proc setPrologueEnv(env: Env; key, value: string) {...}{.inline, raises: [], tags: [].}
- Source Edit
proc writePrologueEnv(filename: string; env: Env) {...}{. raises: [IOError, OSError, Exception], tags: [WriteIOEffect].}
- Source Edit
Funcs
func initEnv(): Env {...}{.inline, raises: [], tags: [].}
- Initializes an Env. Source Edit
func `$`(env: Env): string {...}{.inline, raises: [], tags: [].}
- Gets the string form of Env. Source Edit
func `[]`(env: Env; key: string): string {...}{.inline, raises: [KeyError], tags: [].}
- Source Edit
func hasKey(env: Env; key: string): bool {...}{.inline, raises: [], tags: [].}
- Returns true if key exists in Env. Source Edit
func contains(env: Env; key: string): bool {...}{.inline, raises: [], tags: [].}
- Returns true if key exists in Env. Source Edit
func get(env: Env; key: string): string {...}{.inline, raises: [KeyError], tags: [].}
- Retrieves a value of key in Env. Source Edit
func getOrDefault[T: BaseType](env: Env; key: string; default: T): T {...}{.inline.}
- Retrieves a value of key if key exists in Env. Otherwise the default value will be returned. Source Edit
Exports
-
EmptySecretKeyError, parseValue, getMessage, clear, []=, Fault, types, getMessage, loads, BadSecretKeyError, Warning, parseStringTable, flash, messages, SecretUrl, []=, $, FlashLevel, BaseType, Error, initFormPart, len, newSession, $, dumps, len, Info, Session, del, flash, FormPart, getOrDefault, SecretKey, messagesWithCategory, [], pairs, []