Software /
code /
prosody
Diff
util/argparse.lua @ 12477:cc84682b8429 0.12
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.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 25 Apr 2022 15:24:56 +0100 (2022-04-25) |
parent | 12475:553c6204fe5b |
child | 13058:766152afc1c9 |
line wrap: on
line diff
--- a/util/argparse.lua Mon Apr 25 15:09:41 2022 +0100 +++ b/util/argparse.lua Mon Apr 25 15:24:56 2022 +0100 @@ -5,7 +5,7 @@ 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 @@ 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 {