From 31566d68cb3365ead1cdc8648c81d62ce966cb6f Mon Sep 17 00:00:00 2001 From: dvs1 Date: Fri, 25 Oct 2024 09:38:35 +1000 Subject: Just discovered the arg variable, use it and rename parseArgs() to just parse(). --- _.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '_.lua') diff --git a/_.lua b/_.lua index 88100aa..390d6d1 100755 --- a/_.lua +++ b/_.lua @@ -24,7 +24,7 @@ E = function(s) print('ERROR ' .. s); io.flush() end C = function(s) print('CRITICAL ' .. s); io.flush() end -_.parseArgs = function(options, args) +_.parse = function(args, options) --[[ TODO - use this for config files as well. An optional argument, the base config file name to look for. In this order, with later ones overriding earlier ones - defaults from the options table @@ -34,7 +34,7 @@ _.parseArgs = function(options, args) ]] local o = nil if 0 ~= #args then - for i,a in pairs(args) do + for i,a in ipairs(args) do local s, e = a:find("=") if nil == s then e = 0 end opt = a:sub(1, e - 1) @@ -51,7 +51,7 @@ _.parseArgs = function(options, args) for k, v in pairs(options) do h = h .. k .. ' | ' end - print('Usage: aataaj.lua {' .. string.sub(h, 1, -2) .. '}') + print('Usage: ' .. args[0] .. ' {' .. string.sub(h, 1, -2) .. '}') os.exit(0) end end -- cgit v1.1