@@ -2,25 +2,41 @@ local fs = require 'bee.filesystem'
22local util = require ' utility'
33local version = require ' version'
44
5+ local function getValue (value )
6+ if value == ' true' or value == nil then
7+ value = true
8+ elseif value == ' false' then
9+ value = false
10+ elseif tonumber (value ) then
11+ value = tonumber (value )
12+ elseif value :sub (1 , 1 ) == ' "' and value :sub (- 1 , - 1 ) == ' "' then
13+ value = value :sub (2 , - 2 )
14+ end
15+ return value
16+ end
17+
518local function loadArgs ()
19+ local lastKey
620 for _ , v in ipairs (arg ) do
721 --- @type string
822 local key , tail = v :match ' ^%-%-([%w_]+)(.*)$'
9- if not key then
10- goto CONTINUE
23+ local value
24+ if key then
25+ value = tail :match ' =(.+)'
26+ lastKey = nil
27+ if not value then
28+ lastKey = key
29+ end
30+ else
31+ if lastKey then
32+ key = lastKey
33+ value = v
34+ lastKey = nil
35+ end
1136 end
12- local value = tail :match ' =(.+)'
13- if value == ' true' or value == nil then
14- value = true
15- elseif value == ' false' then
16- value = false
17- elseif tonumber (value ) then
18- value = tonumber (value )
19- elseif value :sub (1 , 1 ) == ' "' and value :sub (- 1 , - 1 ) == ' "' then
20- value = value :sub (2 , - 2 )
37+ if key then
38+ _G [key :upper ()] = getValue (value )
2139 end
22- _G [key :upper ()] = value
23- :: CONTINUE::
2440 end
2541end
2642
0 commit comments