1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-05 00:16:16 +00:00
opus/sys/apis/opus.lua
kepler155c@gmail.com a625b52bad lint
2017-10-08 17:45:01 -04:00

56 lines
1.1 KiB
Lua

local colors = _G.colors
local fs = _G.fs
local os = _G.os
--local shell = _ENV.shell
local term = _G.term
local Opus = { }
local function runDir(directory, open)
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)
if result then
if term.isColor() then
term.setTextColor(colors.green)
end
term.write('[PASS] ')
term.setTextColor(colors.white)
term.write(fs.combine(directory, file))
else
if term.isColor() then
term.setTextColor(colors.red)
end
term.write('[FAIL] ')
term.setTextColor(colors.white)
term.write(fs.combine(directory, file))
if err then
_G.printError(err)
end
success = false
end
print()
end
return success
end
function Opus.loadServices()
return runDir('sys/services', shell.openHiddenTab)
end
function Opus.autorun()
local s = runDir('sys/autorun', shell.run)
return runDir('usr/autorun', shell.run) and s
end
return Opus