This module contains basic configure facilities like retrieving, setting environment variables and so on.
Example:
import src/prologue/core/configure 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"
Types
ConfigFileExt = enum Json = "json", Toml = "toml", Yaml = "yaml"
- Source Edit
EnvWrongFormatError = object of EnvError
- Source Edit
Procs
proc delPrologueEnv(key: string; prefix: string) {.inline, ...raises: [OSError], tags: [WriteEnvEffect], forbids: [].}
- Source Edit
proc existsPrologueEnv(key: string; prefix: string): bool {.inline, ...raises: [], tags: [ReadEnvEffect], forbids: [].}
- Source Edit
proc getAllPrologueEnv(prefix: string): OrderedTableRef[string, string] {. inline, ...raises: [], tags: [ReadEnvEffect], forbids: [].}
- Gets all (key, val) pairs with prefix from environment variables. 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
proc getPrologueEnv(): string {....raises: [], tags: [ReadEnvEffect], forbids: [].}
- Gets PROLOGUE env variables. Source Edit
proc getPrologueEnv(key: string; prefix: string; default = ""): string {.inline, ...raises: [], tags: [ReadEnvEffect], forbids: [].}
- Gets (key, val) pairs with prefix from environment variables. If key can't be found, default will be returned. Source Edit
proc loadPrologueEnv(filename: string): Env {. ...raises: [IOError, OSError, Exception, ValueError, EnvWrongFormatError], tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
- Source Edit
proc putPrologueEnv(key, val: string; prefix: string) {.inline, ...raises: [OSError], tags: [WriteEnvEffect], forbids: [].}
- Puts (key, val) pairs with prefix to environment variables. Source Edit
proc setPrologueEnv(env: Env; key, value: string) {.inline, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc writePrologueEnv(filename: string; env: Env) {....raises: [IOError, OSError], tags: [WriteIOEffect], forbids: [].}
- Source Edit
Exports
-
EmptySecretKeyError, parseValue, getMessage, clear, []=, Fault, getMessage, loads, BadSecretKeyError, Warning, parseStringTable, flash, messages, SecretUrl, []=, $, FlashLevel, BaseType, Error, initFormPart, len, newSession, $, dumps, [], Info, Session, del, flash, FormPart, getOrDefault, SecretKey, messagesWithCategory, [], pairs, len