mirror of
https://github.com/kepler155c/opus
synced 2024-06-18 11:20:01 +00:00
shell completion
This commit is contained in:
parent
e821241cfe
commit
e50e6da700
|
@ -1,13 +1,18 @@
|
||||||
-- Get file to edit
|
shell.setCompletionFunction(shell.getRunningProgram(), function(shell, index, text)
|
||||||
|
if index == 1 then
|
||||||
|
return fs.complete(text, shell.dir(), true, false)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
local tArgs = { ... }
|
local tArgs = { ... }
|
||||||
if #tArgs == 0 then
|
if #tArgs == 0 then
|
||||||
error( "Usage: edit <path>" )
|
error( "Usage: edit <path>" )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Error checking
|
-- Error checking
|
||||||
local sPath = shell.resolve( tArgs[1] )
|
local sPath = shell.resolve(tArgs[1])
|
||||||
local bReadOnly = fs.isReadOnly( sPath )
|
local bReadOnly = fs.isReadOnly(sPath)
|
||||||
if fs.exists( sPath ) and fs.isDir( sPath ) then
|
if fs.exists(sPath) and fs.isDir(sPath) then
|
||||||
error( "Cannot edit a directory." )
|
error( "Cannot edit a directory." )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
53
sys/apps/webapp.lua
Normal file
53
sys/apps/webapp.lua
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
local args = { ... }
|
||||||
|
local GIT_USER = 'kepler155c'
|
||||||
|
local GIT_REPO = 'opus'
|
||||||
|
local GIT_BRANCH = 'develop'
|
||||||
|
local BASE = 'https://raw.githubusercontent.com/kepler155c/opus/develop/'
|
||||||
|
|
||||||
|
local function dourl(env, url)
|
||||||
|
local h = http.get(url)
|
||||||
|
if h then
|
||||||
|
local fn, m = load(h.readAll(), url, nil, env)
|
||||||
|
h.close()
|
||||||
|
if fn then
|
||||||
|
return fn()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
error('Failed to download ' .. url)
|
||||||
|
end
|
||||||
|
|
||||||
|
local s, m = pcall(function()
|
||||||
|
|
||||||
|
_G.requireInjector = dourl(getfenv(1), BASE .. 'sys/apis/injector.lua')
|
||||||
|
|
||||||
|
local function mkenv()
|
||||||
|
local env = { }
|
||||||
|
for k,v in pairs(getfenv(1)) do
|
||||||
|
env[k] = v
|
||||||
|
end
|
||||||
|
setmetatable(env, { __index = _G })
|
||||||
|
return env
|
||||||
|
end
|
||||||
|
|
||||||
|
-- install vfs
|
||||||
|
dourl(mkenv(), BASE .. 'sys/extensions/vfs.lua')
|
||||||
|
|
||||||
|
-- install filesystem
|
||||||
|
fs.mount('', 'gitfs', GIT_USER, GIT_REPO, GIT_BRANCH)
|
||||||
|
|
||||||
|
-- start program
|
||||||
|
local file = table.remove(args, 1)
|
||||||
|
|
||||||
|
local s, m = os.run(mkenv(), file or 'startup', unpack(args))
|
||||||
|
if not s and m then
|
||||||
|
error(m)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if not s and m then
|
||||||
|
printError(m)
|
||||||
|
end
|
||||||
|
|
||||||
|
if fs.restore then
|
||||||
|
fs.restore()
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user