aboutsummaryrefslogtreecommitdiff
path: root/nomsu.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-01-30 16:40:05 -0800
committerBruce Hill <bitbucket@bruce-hill.com>2018-01-30 16:40:23 -0800
commit2dbf2d8810de19a2f06480798307b5bf781671a8 (patch)
treee583af73fa99a56c92db874586f3dcfbcb38c033 /nomsu.moon
parent78c15a5d5e9336f0164161c77c0441b41c226895 (diff)
Cleanup of REPL and detection of command-line running.
Diffstat (limited to 'nomsu.moon')
-rwxr-xr-xnomsu.moon7
1 files changed, 5 insertions, 2 deletions
diff --git a/nomsu.moon b/nomsu.moon
index 0f9ebbf..639315c 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -927,7 +927,8 @@ class NomsuCompiler
nomsu\require_file(filename)
return statements:"nomsu:require_file(#{repr filename});"
-if arg
+-- Only run this code if this file was run directly with command line arguments, and not require()'d:
+if arg and debug.getinfo(2).func != require
export colors
colors = require 'consolecolors'
parser = re.compile([[
@@ -979,13 +980,15 @@ if arg
-- REPL
nomsu\run('use "lib/core.nom"', "stdin")
while true
+ io.write(colored.bright colored.yellow ">> ")
buff = ""
while true
- io.write(">> ")
line = io.read("*L")
if line == "\n" or not line
break
+ line = line\gsub("\t", " ")
buff ..= line
+ io.write(colored.dim colored.yellow ".. ")
if #buff == 0
break
ok, ret = pcall(-> nomsu\run(buff, "stdin"))