mirror of https://github.com/kepler155c/opus
better startup
This commit is contained in:
parent
f2e1a39584
commit
13efde276d
|
@ -391,13 +391,21 @@ function Util.loadUrl(url, env) -- loadfile equivalent
|
||||||
end
|
end
|
||||||
|
|
||||||
function Util.runUrl(env, url, ...) -- os.run equivalent
|
function Util.runUrl(env, url, ...) -- os.run equivalent
|
||||||
|
setmetatable(env, { __index = _G })
|
||||||
local fn, m = Util.loadUrl(url, env)
|
local fn, m = Util.loadUrl(url, env)
|
||||||
if fn then
|
if fn then
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
fn, m = pcall(function() fn(unpack(args)) end)
|
return pcall(function() return fn(table.unpack(args)) end)
|
||||||
end
|
end
|
||||||
if not fn and m and m ~= '' then
|
return fn, m
|
||||||
-- printError(m)
|
end
|
||||||
|
|
||||||
|
function Util.run(env, path, ...)
|
||||||
|
setmetatable(env, { __index = _G })
|
||||||
|
local fn, m = loadfile(path, env)
|
||||||
|
if fn then
|
||||||
|
local args = { ... }
|
||||||
|
return pcall(function() return fn(table.unpack(args)) end)
|
||||||
end
|
end
|
||||||
return fn, m
|
return fn, m
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ local env = {
|
||||||
aliases = shell.aliases(),
|
aliases = shell.aliases(),
|
||||||
lua_path = LUA_PATH,
|
lua_path = LUA_PATH,
|
||||||
}
|
}
|
||||||
Config.load('multishell', env)
|
Config.load('shell', env)
|
||||||
|
|
||||||
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ function systemPage.tabs.pathTab:eventHandler(event)
|
||||||
env.path = self.entry.value
|
env.path = self.entry.value
|
||||||
self.grid:setIndex(self.grid:getIndex())
|
self.grid:setIndex(self.grid:getIndex())
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
Config.update('multishell', env)
|
Config.update('shell', env)
|
||||||
systemPage.notification:success('reboot to take effect')
|
systemPage.notification:success('reboot to take effect')
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -148,7 +148,7 @@ function systemPage.tabs.aliasTab:eventHandler(event)
|
||||||
env.aliases[self.grid:getSelected().alias] = nil
|
env.aliases[self.grid:getSelected().alias] = nil
|
||||||
self.grid:setIndex(self.grid:getIndex())
|
self.grid:setIndex(self.grid:getIndex())
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
Config.update('multishell', env)
|
Config.update('shell', env)
|
||||||
systemPage.notification:success('reboot to take effect')
|
systemPage.notification:success('reboot to take effect')
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ function systemPage.tabs.aliasTab:eventHandler(event)
|
||||||
self.path:reset()
|
self.path:reset()
|
||||||
self:draw()
|
self:draw()
|
||||||
self:setFocus(self.alias)
|
self:setFocus(self.alias)
|
||||||
Config.update('multishell', env)
|
Config.update('shell', env)
|
||||||
systemPage.notification:success('reboot to take effect')
|
systemPage.notification:success('reboot to take effect')
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,14 +61,12 @@ function shell.run(...)
|
||||||
|
|
||||||
local result, err
|
local result, err
|
||||||
|
|
||||||
|
local env = Util.shallowCopy(sandboxEnv)
|
||||||
if isUrl then
|
if isUrl then
|
||||||
local env = Util.shallowCopy(sandboxEnv)
|
|
||||||
setmetatable(env, { __index = _G })
|
|
||||||
result, err = Util.runUrl(env, path, unpack(args))
|
result, err = Util.runUrl(env, path, unpack(args))
|
||||||
else
|
else
|
||||||
result, err = os.run(Util.shallowCopy(sandboxEnv), path, unpack(args))
|
result, err = Util.run(env, path, unpack(args))
|
||||||
end
|
end
|
||||||
|
|
||||||
if multishell and multishell.getTitle then
|
if multishell and multishell.getTitle then
|
||||||
local title = 'shell'
|
local title = 'shell'
|
||||||
if #tProgramStack > 0 then
|
if #tProgramStack > 0 then
|
||||||
|
@ -237,7 +235,7 @@ if #tArgs > 0 then
|
||||||
-- Run the program specified in this new shell
|
-- Run the program specified in this new shell
|
||||||
local s, m = shell.run( ... )
|
local s, m = shell.run( ... )
|
||||||
if not s and m and m ~= 'Terminated' then
|
if not s and m and m ~= 'Terminated' then
|
||||||
error(m or '')
|
error(m)
|
||||||
end
|
end
|
||||||
return s, m
|
return s, m
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,16 +44,9 @@ end
|
||||||
local function run(file, ...)
|
local function run(file, ...)
|
||||||
local s, m = loadfile(file, makeEnv())
|
local s, m = loadfile(file, makeEnv())
|
||||||
if s then
|
if s then
|
||||||
local args = { ... }
|
return s(...)
|
||||||
s, m = pcall(function()
|
|
||||||
return s(table.unpack(args))
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
error('Error loading ' .. file .. '\n' .. m)
|
||||||
if not s and m then
|
|
||||||
error('Error loading ' .. file .. '\n' .. m)
|
|
||||||
end
|
|
||||||
return m
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function runUrl(file, ...)
|
local function runUrl(file, ...)
|
||||||
|
@ -98,7 +91,7 @@ if not fs.exists('usr/config/shell') then
|
||||||
Util.writeTable('usr/config/shell', {
|
Util.writeTable('usr/config/shell', {
|
||||||
aliases = shell.aliases(),
|
aliases = shell.aliases(),
|
||||||
path = 'usr/apps:sys/apps:' .. shell.path(),
|
path = 'usr/apps:sys/apps:' .. shell.path(),
|
||||||
LUA_PATH = '/sys/apis:/usr/apis',
|
lua_path = '/sys/apis:/usr/apis',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -113,7 +106,7 @@ if config.aliases then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
shell.setPath(config.path)
|
shell.setPath(config.path)
|
||||||
LUA_PATH = config.LUA_PATH
|
LUA_PATH = config.lua_path
|
||||||
|
|
||||||
-- extensions
|
-- extensions
|
||||||
local dir = 'sys/extensions'
|
local dir = 'sys/extensions'
|
||||||
|
|
2108
sys/etc/recipes.db
2108
sys/etc/recipes.db
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue