From 93347db1241f8c803c24c6cf615389cb237f0031 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 25 Apr 2022 15:24:56 +0100 Subject: util.argparse: Revise 553c6204fe5b with a different approach The second return value is (not insensibly) assumed to be an error. Instead of returning a value there in the success case, copy the positional arguments into the existing opts table. --- util/argparse.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/argparse.lua b/util/argparse.lua index 6d227b5b..9ece050a 100644 --- a/util/argparse.lua +++ b/util/argparse.lua @@ -5,7 +5,7 @@ local function parse(arg, config) local parsed_opts = {}; if #arg == 0 then - return parsed_opts, arg; + return parsed_opts; end while true do local raw_param = arg[1]; @@ -47,7 +47,10 @@ local function parse(arg, config) end parsed_opts[param_k] = param_v; end - return parsed_opts, arg; + for i = 1, #arg do + parsed_opts[i] = arg[i]; + end + return parsed_opts; end return { -- cgit v1.2.3