mirror of
https://github.com/love2d/love.git
synced 2026-08-20 12:40:20 +02:00
Merged in xpol/love/better-parse-options (pull request #71)
Better love.arg.parse_options():
This commit is contained in:
@@ -122,11 +122,10 @@ function love.arg.parse_option(m, i)
|
|||||||
m.arg = {}
|
m.arg = {}
|
||||||
for j=i,i+m.a-1 do
|
for j=i,i+m.a-1 do
|
||||||
table.insert(m.arg, arg[j])
|
table.insert(m.arg, arg[j])
|
||||||
i = j
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return i
|
return m.a
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.arg.parse_options()
|
function love.arg.parse_options()
|
||||||
@@ -134,15 +133,17 @@ function love.arg.parse_options()
|
|||||||
local game
|
local game
|
||||||
local argc = #arg
|
local argc = #arg
|
||||||
|
|
||||||
for i=1,argc do
|
local i = 1
|
||||||
|
while i <= argc do
|
||||||
-- Look for options.
|
-- 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
|
if m and love.arg.options[m] then
|
||||||
i = love.arg.parse_option(love.arg.options[m], i+1)
|
i = i + love.arg.parse_option(love.arg.options[m], i+1)
|
||||||
elseif not game then
|
elseif not game then
|
||||||
game = i
|
game = i
|
||||||
end
|
end
|
||||||
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if not love.arg.options.game.set then
|
if not love.arg.options.game.set then
|
||||||
|
|||||||
Reference in New Issue
Block a user