1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00
CC-Tweaked/src/main/resources/assets/computercraft/lua/rom/programs/list.lua
SquidDev 86e0330100 Lint bios and the rom (#321)
We now use illuaminate[1]'s linting facilities to check the rom and
bios.lua for a couple of common bugs and other problems.

Right now this doesn't detect any especially important bugs, though it
has caught lots of small things (unused variables, some noisy code). In
the future, the linter will grow in scope and features, which should
allow us to be stricter and catch most issues.

As a fun aside, we started off with ~150 bugs, and illuaminate was able
to fix all but 30 of them, which is pretty neat.

[1]: https://github.com/SquidDev/illuaminate
2019-12-03 23:26:13 +00:00

39 lines
894 B
Lua

local tArgs = { ... }
-- Get all the files in the directory
local sDir = shell.dir()
if tArgs[1] ~= nil then
sDir = shell.resolve( tArgs[1] )
end
if not fs.isDir( sDir ) then
printError( "Not a directory" )
return
end
-- Sort into dirs/files, and calculate column count
local tAll = fs.list( sDir )
local tFiles = {}
local tDirs = {}
local bShowHidden = settings.get( "list.show_hidden" )
for _, sItem in pairs( tAll ) do
if bShowHidden or string.sub( sItem, 1, 1 ) ~= "." then
local sPath = fs.combine( sDir, sItem )
if fs.isDir( sPath ) then
table.insert( tDirs, sItem )
else
table.insert( tFiles, sItem )
end
end
end
table.sort( tDirs )
table.sort( tFiles )
if term.isColour() then
textutils.pagedTabulate( colors.green, tDirs, colors.white, tFiles )
else
textutils.pagedTabulate( tDirs, tFiles )
end