1
0
Fork 0
mirror of https://github.com/Reuh/candran.git synced 2025-10-27 17:59:30 +00:00
candran/bin/can
Reuh ce4a44cb13 Fixed leaving debug code
And oh, I forgot in the last commit: I added a rockspec, which hopefully
works. Soon in LuaRocks repos near you.
2017-08-16 22:38:20 +02:00

37 lines
780 B
Lua

#!/bin/lua
local candran = require("candran")
local cmdline = require("lib.cmdline")
local args = cmdline(arg)
if args.help or args.h then
print("Candran interpreter version "..candran.VERSION.." by Reuh")
print("Usage: "..arg[0].." [target=<target>] [options] filename")
return
end
if #args >= 1 then
candran.dofile(args[1], args)
else -- REPL
print("Candran " .. candran.VERSION)
candran.setup()
while true do
io.write("> ")
local line = io.read()
if line:match("^=") then
line = line:gsub("^=", "return tostring(") .. ")"
end
local t = { pcall(candran.load, line, "stdin") }
if t[1] == false then
print(t[2])
else
t = { pcall(t[2]) }
if t[1] == false then
print(t[2])
elseif #t > 1 then
print(unpack(t, 2))
end
end
end
end