diff options
-rwxr-xr-x | _.lua | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -11,6 +11,7 @@ local _ = {} | |||
11 | _.version = '0.0 crap' | 11 | _.version = '0.0 crap' |
12 | 12 | ||
13 | 13 | ||
14 | -- This sets the global values, here and in the caller. | ||
14 | D = function(s) print('DEBUG ' .. s); io.flush() end | 15 | D = function(s) print('DEBUG ' .. s); io.flush() end |
15 | I = function(s) print('INFO ' .. s); io.flush() end | 16 | I = function(s) print('INFO ' .. s); io.flush() end |
16 | T = function(s) print('TIMEOUT ' .. s); io.flush() end | 17 | T = function(s) print('TIMEOUT ' .. s); io.flush() end |
@@ -20,6 +21,13 @@ C = function(s) print('CRITICAL ' .. s); io.flush() end | |||
20 | 21 | ||
21 | 22 | ||
22 | _.parseArgs = function(options, args) | 23 | _.parseArgs = function(options, args) |
24 | --[[ TODO - use this for config files as well. | ||
25 | An optional argument, the base config file name to look for. In this order, with later ones overriding earlier ones - | ||
26 | defaults from the options table | ||
27 | /etc/base.conf.lua | ||
28 | ~/.base.conf.lua | ||
29 | command line arguments | ||
30 | ]] | ||
23 | local o = nil | 31 | local o = nil |
24 | if 0 ~= #args then | 32 | if 0 ~= #args then |
25 | for i,a in pairs(args) do | 33 | for i,a in pairs(args) do |
@@ -29,7 +37,7 @@ _.parseArgs = function(options, args) | |||
29 | o = options[opt] | 37 | o = options[opt] |
30 | D('Argument ' .. i .. ' = ' .. a) | 38 | D('Argument ' .. i .. ' = ' .. a) |
31 | if nil ~= o then | 39 | if nil ~= o then |
32 | o:func(a, args, i) | 40 | if nil ~= o.func then o:func(a, args, i) end |
33 | end | 41 | end |
34 | end | 42 | end |
35 | end | 43 | end |
@@ -206,9 +214,9 @@ __ = function(c) | |||
206 | if (137 == self.status) or (124 == self.status) then | 214 | if (137 == self.status) or (124 == self.status) then |
207 | T("timeout killed " .. self.status .. ' ' .. self.command) | 215 | T("timeout killed " .. self.status .. ' ' .. self.command) |
208 | elseif (nil == self.status) then | 216 | elseif (nil == self.status) then |
209 | I("STATUS |" .. "NIL" .. '| ' .. self.command) | 217 | D("STATUS |" .. "NIL" .. '| ' .. self.command) |
210 | elseif (0 ~= self.status) then | 218 | elseif (0 ~= self.status) then |
211 | I("STATUS |" .. self.status .. '| ' .. self.command) | 219 | D("STATUS |" .. self.status .. '| ' .. self.command) |
212 | end | 220 | end |
213 | return self | 221 | return self |
214 | end | 222 | end |