From 194a19090d328055c7635fee7267be2bb7c68fe6 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Thu, 24 Oct 2024 12:34:41 +1000 Subject: Mostly minor cleanups. --- _.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to '_.lua') diff --git a/_.lua b/_.lua index b86eda0..f5ab5b9 100755 --- a/_.lua +++ b/_.lua @@ -11,6 +11,7 @@ local _ = {} _.version = '0.0 crap' +-- This sets the global values, here and in the caller. D = function(s) print('DEBUG ' .. s); io.flush() end I = function(s) print('INFO ' .. s); io.flush() end T = function(s) print('TIMEOUT ' .. s); io.flush() end @@ -20,6 +21,13 @@ C = function(s) print('CRITICAL ' .. s); io.flush() end _.parseArgs = function(options, args) +--[[ 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 + /etc/base.conf.lua + ~/.base.conf.lua + command line arguments +]] local o = nil if 0 ~= #args then for i,a in pairs(args) do @@ -29,7 +37,7 @@ _.parseArgs = function(options, args) o = options[opt] D('Argument ' .. i .. ' = ' .. a) if nil ~= o then - o:func(a, args, i) + if nil ~= o.func then o:func(a, args, i) end end end end @@ -206,9 +214,9 @@ __ = function(c) if (137 == self.status) or (124 == self.status) then T("timeout killed " .. self.status .. ' ' .. self.command) elseif (nil == self.status) then - I("STATUS |" .. "NIL" .. '| ' .. self.command) + D("STATUS |" .. "NIL" .. '| ' .. self.command) elseif (0 ~= self.status) then - I("STATUS |" .. self.status .. '| ' .. self.command) + D("STATUS |" .. self.status .. '| ' .. self.command) end return self end -- cgit v1.1