-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandLine.lua
60 lines (47 loc) · 1.92 KB
/
CommandLine.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-- CommandLine.lua
-- AUTHOR: Michael Peterson
-- ORIGINAL DATE: 14 June, 2019
--------------------------------------------------------------------------------------
local ADDON_NAME, ChaChing = ...
ChaChing = ChaChing or {}
ChaChing.CommandLine = {}
local core = ChaChing.Core
local mf = ChaChing.MsgFrame
local dbg = ChaChing.DebugTools
local L = ChaChing.L
---------------------------------------------------------------------------------------------------
--COMMAND LINE OPTIONS
--------------------------------------------------------------------------------------------------
-- Command line parsing: https://wowpedia.fandom.com/wiki/Creating_a_slash_command
local helpMsg = "Not Yet Implemented"
local function postHelpMsg()
mf:postMsg( string.format("See README.md\n"))
end
-- Command handler function
local function ChaChingCommands(optionStr, editbox)
dbg:print("Command received: " .. optionStr)
-- Pattern matching that skips leading whitespace and whitespace between option and argList
-- Any whitespace at end of the argList is retained
local _, _, option, argList = string.find(optionStr, "%s?(%w+)%s?(.*)")
dbg:print("Option: " .. (option or "nil") .. ", Arguments: " .. (argList or "nil"))
if option == nil or option == "help" or option == "" or option == '?' then
postHelpMsg()
return
end
option = string.lower(option)
if option == "set" then
if argList == "debug" then
core:enableDebugging()
mf:postMsg("Debugging enabled.")
return
end
end
-- If not handled above, display some sort of help message
postHelpMsg()
end
SLASH_CHACHING1 = "/cc"
SlashCmdList["CHACHING"] = ChaChingCommands
local fileName = "CommandLine.lua"
if core:debuggingIsEnabled() then
DEFAULT_CHAT_FRAME:AddMessage(string.format("%s loaded", fileName), 1.0, 1.0, 0.0)
end