I'd like to write an addon that use such usage syntax:
/remgank - This help
/remgank add <player_name> <note> - Add a ganker
/remgank del <player_name> - Remove a ganker
/remgank lst - List gankers
I begin with:
Lua Code:
SlashCmdList["REMGANK"] = function(args)
local args=SecureCmdOptionParse(args:trim());
cmd, name, note = args:match("(%w+)%s+(%w+)%s+(.*)")
cmd, name = args:match("(%w+)%s+(%w)")
cmd = args:match("(%w+)")
if (cmd == "" or cmd == nil) then
print(prgname .. " commands");
print("/remgank - This help");
print("/remgank add <player_name> <note> - Add a ganker");
print("/remgank del <player_name> - Remove a ganker");
print("/remgank lst - List those silly gankers");
return;
end
if cmd:lower() == "add" then
....
Is there a better way to parse the cmd line when we doesn't know the number of args before ?
It should be somewhere a global array for them I think ... but I tried all the afternoon without any success in finding a more beautifull way to parse :-/
Thanks for any tips/clues if any.