aboutsummaryrefslogtreecommitdiff
path: root/nomsu.lua
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-29 16:16:45 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-29 16:17:33 -0800
commitbc41cc3a244bf47679d1c47d17006a2aa7356bc8 (patch)
tree102ec25b54f795d7a24648faa129f4dbccef3619 /nomsu.lua
parentfebe7e82e06e1071c312f449b1ced319ef9a6932 (diff)
Switched to have colors/utf8 be optional, fixed an issue with currently
running files leaking when errors occurred (causing spurious circular import errors), and improved tutorial.
Diffstat (limited to 'nomsu.lua')
-rw-r--r--nomsu.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/nomsu.lua b/nomsu.lua
index dc5b97f..21e4af2 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -1,16 +1,17 @@
local clibtype = package.cpath:match("?%.(so)") or package.cpath:match("?%.(dll)")
+COLOR_ENABLED = true
if clibtype == "dll" then
+ local enable_colors = require('wincolors')
+ local ok, _ = pcall(enable_colors)
+ if not ok then
+ COLOR_ENABLED = false
+ end
os.execute("chcp 65001>nul")
end
if NOMSU_VERSION and NOMSU_PREFIX then
package.path = tostring(NOMSU_PREFIX) .. "/share/nomsu/" .. tostring(NOMSU_VERSION) .. "/?.lua;" .. package.path
package.cpath = tostring(NOMSU_PREFIX) .. "/lib/nomsu/" .. tostring(NOMSU_VERSION) .. "/?." .. tostring(clibtype) .. ";" .. package.cpath
end
-local EXIT_SUCCESS, EXIT_FAILURE = 0, 1
-if _VERSION == "Lua 5.1" and not jit then
- print("Sorry, Nomsu does not run on Lua 5.1. Please use LuaJIT 2+ or Lua 5.2+")
- os.exit(EXIT_FAILURE)
-end
local usage = [=[Nomsu Compiler
Usage: (nomsu | lua nomsu.lua | moon nomsu.moon) [-V version] [--help | -h] [--version] [-O optimization level] [-v] [-c] [-s] [-d debugger] [--no-core] [(file | -t tool | -e "nomsu code..." | files... -- ) [nomsu args...]]
@@ -92,7 +93,7 @@ local arg_string = table.concat(arg, sep) .. sep
local args, err = parser:match(arg_string)
if not args or err or args.help then
if err then
- print("Didn't understand: \x1b[31;1m" .. tostring(err) .. "\x1b[0m")
+ print("Didn't understand: " .. tostring(err))
end
print(usage)
os.exit(EXIT_FAILURE)
@@ -142,6 +143,7 @@ nomsu_environment.COMMAND_LINE_ARGS = nomsu_args
nomsu_environment.OPTIMIZATION = optimization
nomsu_environment.NOMSU_PACKAGEPATH = NOMSU_PACKAGEPATH
nomsu_environment.NOMSU_PREFIX = NOMSU_PREFIX
+nomsu_environment.COLOR_ENABLED = COLOR_ENABLED
local run
run = function()
if not (args.no_core) then