shell completion

This commit is contained in:
kepler155c@gmail.com
2017-09-06 09:06:04 -04:00
parent e821241cfe
commit e50e6da700
2 changed files with 62 additions and 4 deletions

View File

@@ -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 = { ... }
if #tArgs == 0 then
error( "Usage: edit <path>" )
end
-- Error checking
local sPath = shell.resolve( tArgs[1] )
local bReadOnly = fs.isReadOnly( sPath )
if fs.exists( sPath ) and fs.isDir( sPath ) then
local sPath = shell.resolve(tArgs[1])
local bReadOnly = fs.isReadOnly(sPath)
if fs.exists(sPath) and fs.isDir(sPath) then
error( "Cannot edit a directory." )
end