Skip to content

Commit 8917a0d

Browse files
authored
Merge pull request #19 from Numynum/patch-2
Improve secret handling, and fix function call returns being broken
2 parents 39013a3 + 64a1ee4 commit 8917a0d

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

DevTool.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ function DevTool:UIUpdateMainTableButton(element, info, id)
529529

530530
element.nameButton:SetPoint("LEFT", element.rowNumberButton, "RIGHT", 10 * info.indentation - 10, 0)
531531

532-
element.valueButton:SetText(DevTool.ToUIString(info.value, info.name, true))
532+
element.valueButton:GetFontString():SetText(DevTool.ToUIString(info.value, info.name, true))
533533
element.nameButton:SetText(tostring(info.name))
534534
element.rowNumberButton:SetText(tostring(id))
535535

@@ -765,16 +765,16 @@ function DevTool:ProcessCallFunctionData(ok, info, parent, args, results)
765765
-- for example 1, 2, nil, 4 should return only this 4 values nothing more, nothing less.
766766
local found = false
767767
for i = 10, 1, -1 do
768-
local result = DevTool.secretToString(results[i])
768+
local result = results[i]
769769
if result ~= nil then
770770
found = true
771771
end
772772

773773
if found or i == 1 then
774774
-- if found some return or if return is nil
775-
table.insert(elements, self:NewElement(result, string.format(" return: %d", i), indentation))
775+
elements[i] = self:NewElement(result, string.format(" return: %d", i), indentation)
776776

777-
returnFormattedStr = string.format(" %s (%s)%s", tostring(result),
777+
returnFormattedStr = string.format(" %s (%s)%s", DevTool.secretToString(result),
778778
self.colors.lightblue:WrapTextInColorCode(type(result)), returnFormattedStr)
779779
end
780780
end
@@ -791,8 +791,8 @@ function DevTool:ProcessCallFunctionData(ok, info, parent, args, results)
791791

792792
self:UpdateMainTableUI()
793793

794-
--print info to chat
795-
self:Print(stateStr(ok) .. " " .. fnNameWithArgs .. self.colors.gray:WrapTextInColorCode(" returns:") .. returnFormattedStr)
794+
--print info to chat (not using self:Print since AceConsole:Print currently doesn't support secrets)
795+
print("|cff33ff99DevTool|r:", stateStr(ok), fnNameWithArgs, self.colors.gray:WrapTextInColorCode("returns:"), returnFormattedStr)
796796
end
797797

798798
-----------------------------------------------------------------------------------------------

Utilities/Utils.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,16 @@ end
165165

166166
function DevTool.ToUIString(value, name, withoutLineBrakes)
167167
local result
168-
value = DevTool.secretToString(value)
169168
local valueType = type(value)
170169

171170
if valueType == "table" then
172-
result = DevTool.GetObjectInfoFromWoWAPI(name, value) or tostring(value)
171+
result = DevTool.GetObjectInfoFromWoWAPI(name, value) or DevTool.secretToString(value)
173172
result = "(" .. DevTool.CountElements(value) .. ") " .. result
174173
else
175-
result = tostring(value)
174+
result = DevTool.secretToString(value)
176175
end
177176

178-
if withoutLineBrakes then
177+
if withoutLineBrakes and not DevTool.isSecret(result) then
179178
result = string.gsub(string.gsub(tostring(result), "|n", ""), "\n", "")
180179
end
181180

@@ -247,7 +246,7 @@ function DevTool.GetObjectInfoFromWoWAPI(helperText, value)
247246

248247
resultStr = concat(texture)
249248
resultStr = concat(text, "'", "'")
250-
resultStr = concat(tostring(value))
249+
resultStr = concat(DevTool.secretToString(value))
251250
end
252251

253252
return resultStr
@@ -323,9 +322,9 @@ function DevTool.isSecret(value)
323322
return false
324323
end
325324

326-
function DevTool.secretToString(value)
325+
function DevTool.secretToString(value, withoutPrefix)
327326
if DevTool.isSecret(value) then
328-
return string.format("<SECRET %s>", type(value))
327+
return string.format(withoutPrefix and "%s" or "<SECRET> %s", value)
329328
end
330329
return tostring(value)
331330
end

0 commit comments

Comments
 (0)