aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-14 18:00:59 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-14 18:01:06 -0800
commit706811fed4a91d90a61530fc4c790303d41c566d (patch)
tree595c77ad2d1d0012a77670162ce0442e38e2c334
parentfb19d1af1155fa45a04b1f68b2254da551a3e780 (diff)
Added warning for nomsu -c foo.lua
-rw-r--r--nomsu.lua3
-rwxr-xr-xnomsu.moon2
2 files changed, 5 insertions, 0 deletions
diff --git a/nomsu.lua b/nomsu.lua
index ff1e3fe..a600e9b 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -173,6 +173,9 @@ run = function()
nomsu_environment._1_parsed(NomsuCode:from(source, code))
print("Parse succeeded: " .. tostring(filename))
elseif args.compile then
+ if filename:match("%.lua$") then
+ error("Cannot compile a lua file (expected a nomsu file as input)")
+ end
local output
if filename == 'stdin' then
output = io.output()
diff --git a/nomsu.moon b/nomsu.moon
index fc2fe5a..a55ace4 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -142,6 +142,8 @@ run = ->
print("Parse succeeded: #{filename}")
elseif args.compile
-- Compile .nom files into .lua
+ if filename\match("%.lua$")
+ error("Cannot compile a lua file (expected a nomsu file as input)")
output = if filename == 'stdin' then io.output()
else io.open(filename\gsub("%.nom$", ".lua"), "w")
code = Files.read(filename)