all repos — nifty @ 9d95d6c017d753b61abc05fe436f9b865b4e37d6

A tiny (pseudo) package manager and script runner.

lib/config.nim

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
import
  os,
  parsecfg,
  streams,
  strutils,
  logging

import
  styled_console_logger

const
  cfgfile   = "../nifty.nimble".slurp

var
  appname*: string
  version*: string
  appdesc*: string
  f = newStringStream(cfgfile)

if f != nil:
  var p: CfgParser
  open(p, f, "../minim.nimble")
  while true:
    var e = next(p)
    case e.kind
    of cfgEof:
      break
    of cfgKeyValuePair:
      case e.key:
        of "version":
          version = e.value
        of "name":
          appname = e.value
        of "description":
          appdesc = e.value
        else:
          discard
    of cfgError:
      fatal("Configuration error.")
      quit(1)
    else: 
      discard
  close(p)
else:
  fatal("Cannot process configuration file.")
  quit(2)