From 7076df2b70ff42a00e88882c1f884293fa2dcbbc Mon Sep 17 00:00:00 2001 From: John Pasula Date: Tue, 25 Jan 2011 09:07:01 -0700 Subject: [PATCH] Throw the chat command and its helper functions into a doend block. --- core.lua | 99 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/core.lua b/core.lua index 72f6c60..99b203d 100644 --- a/core.lua +++ b/core.lua @@ -1487,62 +1487,65 @@ function addon:InitializeProfession(profession) end end --- Code snippet stolen from GearGuage by Torhal -local function StrSplit(input) - if not input then return nil, nil end - local arg1, arg2, var1 - - arg1, var1 = input:match("^([^%s]+)%s*(.*)$") - arg1 = (arg1 and arg1:lower() or input:lower()) - - if var1 then - local var2 - arg2, var2 = var1:match("^([^%s]+)%s*(.*)$") - arg2 = (arg2 and arg2:lower() or var1:lower()) +do + -- Code snippet stolen from GearGuage by Torhal + local function StrSplit(input) + if not input then return nil, nil end + local arg1, arg2, var1 + + arg1, var1 = input:match("^([^%s]+)%s*(.*)$") + arg1 = (arg1 and arg1:lower() or input:lower()) + + if var1 then + local var2 + arg2, var2 = var1:match("^([^%s]+)%s*(.*)$") + arg2 = (arg2 and arg2:lower() or var1:lower()) + end + return arg1, arg2 end - return arg1, arg2 -end --- Determines what to do when the slash command is called. -function addon:ChatCommand(input) + -- Determines what to do when the slash command is called. + function addon:ChatCommand(input) - local arg1, arg2 = StrSplit(input) + local arg1, arg2 = StrSplit(input) - -- Open About panel if there's no parameters or if we do /arl about - if not arg1 or (arg1 and arg1:trim() == "") or arg1 == strlower(L["Sorting"]) or arg1 == strlower(L["Sort"]) or arg1 == strlower(_G.DISPLAY) then - InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) - elseif (arg1 == strlower(L["About"])) then - if (self.optionsFrame["About"]) then - InterfaceOptionsFrame_OpenToCategory(self.optionsFrame["About"]) - else + -- Open About panel if there's no parameters or if we do /arl about + if not arg1 or (arg1 and arg1:trim() == "") or arg1 == strlower(L["Sorting"]) or arg1 == strlower(L["Sort"]) or arg1 == strlower(_G.DISPLAY) then InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) - end - elseif (arg1 == strlower(L["Profile"])) then - InterfaceOptionsFrame_OpenToCategory(self.optionsFrame["Profiles"]) - elseif (arg1 == strlower(L["Documentation"])) then - InterfaceOptionsFrame_OpenToCategory(self.optionsFrame["Documentation"]) - elseif (arg1 == strlower(L["Scan"])) then - if not arg2 then - self:Print(L["COMMAND_LINE_SCAN"]) - else - CastSpellByName(arg2) - -- If the ARL window is shown, hide it. - if ARL.Frame and ARL.Frame:IsVisible() then - ARL.Frame:Hide() - -- If not, run the scan. + elseif (arg1 == strlower(L["About"])) then + if (self.optionsFrame["About"]) then + InterfaceOptionsFrame_OpenToCategory(self.optionsFrame["About"]) else - self:Scan(false, false) + InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) end + elseif (arg1 == strlower(L["Profile"])) then + InterfaceOptionsFrame_OpenToCategory(self.optionsFrame["Profiles"]) + elseif (arg1 == strlower(L["Documentation"])) then + InterfaceOptionsFrame_OpenToCategory(self.optionsFrame["Documentation"]) + elseif (arg1 == strlower(L["Scan"])) then + if not arg2 then + self:Print(L["COMMAND_LINE_SCAN"]) + else + CastSpellByName(arg2) + -- If the ARL window is shown, hide it. + if ARL.Frame and ARL.Frame:IsVisible() then + ARL.Frame:Hide() + -- If not, run the scan. + else + self:Scan(false, false) + end + end + elseif (arg1 == strlower("scandata")) then + self:ScanSkillLevelData() + elseif (arg1 == strlower("scanprof")) then + self:ScanProfession("all") + elseif (arg1 == strlower("tradelinks")) then + self:GenerateLinks() + else + -- What happens when we get here? + LibStub("AceConfigCmd-3.0"):HandleCommand("arl", "Ackis Recipe List", arg1) end - elseif (arg1 == strlower("scandata")) then - self:ScanSkillLevelData() - elseif (arg1 == strlower("scanprof")) then - self:ScanProfession("all") - elseif (arg1 == strlower("tradelinks")) then - self:GenerateLinks() - else - -- What happens when we get here? - LibStub("AceConfigCmd-3.0"):HandleCommand("arl", "Ackis Recipe List", arg1) + end end -- 1.7.9.5