better file select for debugger - native support for moonscript
This commit is contained in:
37
moonscript/autorun/startup.lua
Normal file
37
moonscript/autorun/startup.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
local Map = require('opus.map')
|
||||
|
||||
local fs = _G.fs
|
||||
local shell = _ENV.shell
|
||||
|
||||
local commands = Map.transpose {
|
||||
'packages/moonscript/moon',
|
||||
'packages/moonscript/moonc'
|
||||
}
|
||||
|
||||
local function compatEnv(source)
|
||||
local env = Map.shallowCopy(source._G)
|
||||
Map.merge(env, source)
|
||||
env._G = env
|
||||
_G.requireInjector(env, 'packages/moon')
|
||||
return env
|
||||
end
|
||||
|
||||
shell.registerHandler(function(args, env)
|
||||
if args[1]:match('(.+)%.moon$') then
|
||||
return {
|
||||
title = fs.getName(args[1]):match('([^%.]+)'),
|
||||
path = 'packages/moonscript/moon',
|
||||
args = args,
|
||||
load = loadfile,
|
||||
env = compatEnv(env),
|
||||
}
|
||||
end
|
||||
local command = shell.resolveProgram(args[1]) or ''
|
||||
return commands[command] and {
|
||||
title = fs.getName(command),
|
||||
path = command,
|
||||
args = { table.unpack(args, 2) },
|
||||
load = loadfile,
|
||||
env = compatEnv(env),
|
||||
}
|
||||
end)
|
||||
@@ -48,7 +48,7 @@ run = function()
|
||||
require("moonscript.version").print_version()
|
||||
os.exit()
|
||||
end
|
||||
local script_fname = shell.resolve(opts.script)
|
||||
local script_fname = shell.resolveProgram(opts.script)
|
||||
args = {
|
||||
unpack(arg, base + 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user