aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nomsu.lua6
-rwxr-xr-xnomsu.moon7
2 files changed, 9 insertions, 4 deletions
diff --git a/nomsu.lua b/nomsu.lua
index 4c3c9fc..95cd8dc 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -1476,7 +1476,7 @@ do
var_pattern = re.compile("{| %space ((('%' {%varname}) / %word) %space)+ |}", stub_defs)
NomsuCompiler = _class_0
end
-if arg then
+if arg and debug.getinfo(2).func ~= require then
colors = require('consolecolors')
local parser = re.compile([[ args <- {| {:flags: flags? :} ({:input: input :} ";" ("-o;"{:output: output :} ";")?)? (";")? |} !.
flags <- (({| ({flag} ";")* |}) -> set)
@@ -1532,14 +1532,16 @@ if arg then
if args.flags["-i"] then
nomsu:run('use "lib/core.nom"', "stdin")
while true do
+ io.write(colored.bright(colored.yellow(">> ")))
local buff = ""
while true do
- io.write(">> ")
local line = io.read("*L")
if line == "\n" or not line then
break
end
+ line = line:gsub("\t", " ")
buff = buff .. line
+ io.write(colored.dim(colored.yellow(".. ")))
end
if #buff == 0 then
break
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"))