1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-28 01:20:27 +00:00
opus/sys/apis/opus.lua

56 lines
1.1 KiB
Lua
Raw Normal View History

2017-10-08 21:45:01 +00:00
local colors = _G.colors
local fs = _G.fs
local os = _G.os
2017-10-15 06:36:54 +00:00
local shell = _ENV.shell
2017-10-08 21:45:01 +00:00
local term = _G.term
2017-09-06 01:21:43 +00:00
local Opus = { }
2017-09-26 05:40:02 +00:00
local function runDir(directory, open)
2017-09-06 01:21:43 +00:00
if not fs.exists(directory) then
return true
end
local success = true
local files = fs.list(directory)
table.sort(files)
for _,file in ipairs(files) do
os.sleep(0)
local result, err = open(directory .. '/' .. file)
2017-09-26 02:49:44 +00:00
if result then
2017-09-26 03:18:36 +00:00
if term.isColor() then
term.setTextColor(colors.green)
end
2017-09-26 02:49:44 +00:00
term.write('[PASS] ')
term.setTextColor(colors.white)
term.write(fs.combine(directory, file))
else
2017-09-26 03:18:36 +00:00
if term.isColor() then
term.setTextColor(colors.red)
end
2017-09-26 02:49:44 +00:00
term.write('[FAIL] ')
term.setTextColor(colors.white)
term.write(fs.combine(directory, file))
if err then
2017-10-08 21:45:01 +00:00
_G.printError(err)
2017-09-26 02:49:44 +00:00
end
2017-09-06 01:21:43 +00:00
success = false
end
2017-09-26 02:49:44 +00:00
print()
2017-09-06 01:21:43 +00:00
end
return success
end
function Opus.loadServices()
2017-09-26 05:40:02 +00:00
return runDir('sys/services', shell.openHiddenTab)
2017-09-06 01:21:43 +00:00
end
function Opus.autorun()
2017-09-26 05:40:02 +00:00
local s = runDir('sys/autorun', shell.run)
return runDir('usr/autorun', shell.run) and s
2017-09-06 01:21:43 +00:00
end
return Opus