Better love.arg.parse_options():

1. use string.match for we are mean to match
2. better match pattern which now do not allow somthing like `not-a-valid--console`
3. use while loop which allows change loop var.

--HG--
branch : better-parse-options
This commit is contained in:
xpol
2016-11-04 11:37:38 +08:00
parent 3336accb8f
commit de855f30d5
+4 -2
View File
@@ -134,15 +134,17 @@ function love.arg.parse_options()
local game
local argc = #arg
for i=1,argc do
local i = 1
while i <= argc do
-- Look for options.
local s, e, m = string.find(arg[i], "%-%-(.+)")
local m = string.match(arg[i], "^%-%-(.+)")
if m and love.arg.options[m] then
i = love.arg.parse_option(love.arg.options[m], i+1)
elseif not game then
game = i
end
i = i + 1
end
if not love.arg.options.game.set then