This commit is contained in:
Christoph J. Scherr 2024-02-15 14:26:01 +01:00
parent 3e3855bc8a
commit 7176181aef
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
1 changed files with 6 additions and 3 deletions

View File

@ -8,7 +8,7 @@ function tokenize_args(raw)
-- '*?' does not work -- '*?' does not work
-- '|' is not or -- '|' is not or
-- --
-- This means we're better of implementing a programatic lexer. -- This means we're better of implementing the lexer with an algorithm.
local t = {} local t = {}
local current = "" local current = ""
local in_str = false local in_str = false
@ -33,7 +33,9 @@ function tokenize_args(raw)
current = current .. c current = current .. c
end end
end end
table.insert(t, current) if string.len(current) > 0 then
table.insert(t, current)
end
return t return t
end end
@ -58,7 +60,8 @@ function dump(t)
end end
function main() function main()
local mockargs = [[-iab --foo '{"QUX": "BAR"}' --ala=boa]] local mockargs =
[[--name "tls_service_rs" --base-dir ${PWD%/*/*} --log-level "TRACE" -j '{ "MODE": "server", "CERT": "data/server.crt", "KEY": "data/server.key", "CHAIN": "data/root.crt", "ADDR": "127.0.0.1:9999", "HOSTNAME": "localhost" }']]
print(mockargs) print(mockargs)
local split = tokenize_args(mockargs) local split = tokenize_args(mockargs)
print(dump(split)) print(dump(split))