Implemented support for .minimrc.
h3rald h3rald@h3rald.com
Sat, 03 Sep 2016 15:15:17 +0200
1 files changed,
14 insertions(+),
1 deletions(-)
jump to
M
minim.nim
→
minim.nim
@@ -25,6 +25,11 @@
var REPL = false var DEBUGGING = false const PRELUDE* = ".minimrc".slurp.strip +when defined(windows): + const HOME = getenv("HOMEPATH") +when not defined(windows): + const HOME = getenv("HOME") +const MINIMRC = HOME / ".minimrc" let usage* = " MiNiM v" & version & " - a tiny concatenative programming language" & """@@ -65,6 +70,12 @@ when not(USE_LINENOISE):
stdout.write(s) return stdin.readLine +proc saverc() = + MINIMRC.writeFile(PRELUDE) + +proc loadrc(): string = + return MINIMRC.readFile() + proc stdLib(i: In) = i.lang_module i.io_module@@ -76,7 +87,9 @@ i.sys_module
i.time_module i.fs_module i.crypto_module - i.eval PRELUDE + if not MINIMRC.fileExists: + saverc() + i.eval loadrc() proc minimStream(s: Stream, filename: string, debugging = false) = var i = newMinInterpreter(debugging)