Skip to content

Commit

Permalink
refactor: colorize set.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Erb3 authored Jul 9, 2024
1 parent d77f5f1 commit 15f73f4
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ local pp = require "cc.pretty"
local tArgs = { ... }
if #tArgs == 0 then
-- "set"
local _, y = term.getCursorPos()
local tSettings = {}
for n, sName in ipairs(settings.getNames()) do
tSettings[n] = textutils.serialize(sName) .. " is " .. textutils.serialize(settings.get(sName))
pp.print(pp.text(sName, colors.cyan) .. " is " .. pp.pretty(settings.get(sName)))
end
textutils.pagedPrint(table.concat(tSettings, "\n"), y - 3)

elseif #tArgs == 1 then
-- "set foo"
local sName = tArgs[1]
Expand All @@ -24,7 +20,6 @@ elseif #tArgs == 1 then
end
pp.print(msg)
if deets.description then print(deets.description) end

else
-- "set foo bar"
local sName = tArgs[1]
Expand All @@ -45,12 +40,12 @@ else
local option = settings.getDetails(sName)
if value == nil then
settings.unset(sName)
print(textutils.serialize(sName) .. " unset")
pp.print(pp.text(sName, colors.cyan) .. " unset")
elseif option.type and option.type ~= type(value) then
printError(("%s is not a valid %s."):format(textutils.serialize(sValue), option.type))
else
settings.set(sName, value)
print(textutils.serialize(sName) .. " set to " .. textutils.serialize(value))
pp.print(pp.text(sName, colors.cyan) .. " set to " .. pp.pretty(value))
end

if value ~= option.value then
Expand Down

0 comments on commit 15f73f4

Please sign in to comment.