OctOS: Add ls and cat commands
Allow listing the contents of a directory and printing the contents of a file.master
parent
613657d454
commit
84ea1850ce
|
@ -0,0 +1,4 @@
|
|||
name = cat
|
||||
description = Print the contents of a file
|
||||
params = [path]
|
||||
exec = os/exec/cat.lua
|
|
@ -0,0 +1,4 @@
|
|||
name = ls
|
||||
description = List the contents of a directory
|
||||
params = [path]
|
||||
exec = os/exec/ls.lua
|
|
@ -0,0 +1,10 @@
|
|||
local path = ...
|
||||
path = path[1]
|
||||
|
||||
if path then
|
||||
if fs.exists(path) then
|
||||
print(fs.read(path))
|
||||
end
|
||||
else
|
||||
print("Must specify path (see help cat)")
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
local path = ...
|
||||
path = path[1]
|
||||
|
||||
if path then
|
||||
local contents = fs.list(path)
|
||||
local result = table.concat(contents.files, " ") .. " " .. table.concat(contents.subdirs, " ")
|
||||
print(result)
|
||||
else
|
||||
print("Must specify path (see help ls)")
|
||||
end
|
Loading…
Reference in New Issue