aboutsummaryrefslogtreecommitdiffstats
path: root/_.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x_.lua45
1 files changed, 37 insertions, 8 deletions
diff --git a/_.lua b/_.lua
index 19b73b4..12d7461 100755
--- a/_.lua
+++ b/_.lua
@@ -6,13 +6,38 @@ local _ = {}
6_.version = '0.0 crap' 6_.version = '0.0 crap'
7 7
8 8
9D = function(s) print('DEBUG ' .. s) end 9D = function(s) print('DEBUG ' .. s); io.flush() end
10I = function(s) print('INFO ' .. s) end 10I = function(s) print('INFO ' .. s); io.flush() end
11T = function(s) print('TIMEOUT ' .. s) end 11T = function(s) print('TIMEOUT ' .. s); io.flush() end
12W = function(s) print('WARNING ' .. s) end 12W = function(s) print('WARNING ' .. s); io.flush() end
13E = function(s) print('ERROR ' .. s) end 13E = function(s) print('ERROR ' .. s); io.flush() end
14C = function(s) print('CRITICAL ' .. s) end 14C = function(s) print('CRITICAL ' .. s); io.flush() end
15
16
17_.parseArgs = function(options, args)
18 local o = nil
19 if 0 ~= #args then
20 for i,a in pairs(args) do
21 local s, e = a:find("=")
22 if nil == s then e = 0 end
23 opt = a:sub(1, e - 1)
24 o = options[opt]
25 D('Argument ' .. i .. ' = ' .. a)
26 if nil ~= o then
27 o:func(a, args, i)
28 end
29 end
30 end
15 31
32 if nil == o then
33 local h = ''
34 for k, v in pairs(options) do
35 h = h .. k .. '|'
36 end
37 print('Usage: aataaj.lua {' .. string.sub(h, 1, -2) .. '}')
38 os.exit(0)
39 end
40end
16 41
17_.runnable = function(c) 42_.runnable = function(c)
18 return ( 0 == __('which ' .. c):Do().status ) 43 return ( 0 == __('which ' .. c):Do().status )
@@ -66,8 +91,12 @@ __ = function(c)
66 elseif 'string' == type(c) then 91 elseif 'string' == type(c) then
67 for l in string.gmatch(c, "\n*([^\n]+)\n*") do 92 for l in string.gmatch(c, "\n*([^\n]+)\n*") do
68 if '' ~= l then 93 if '' ~= l then
69 n = n + 1 94 if ('#!' == l:sub(1,2)) and (n == 0) then
70 exe.cmd = exe.cmd .. l .. ' ; ' 95 -- TODO - should do something with this, not just run it as shell stuff.
96 else
97 n = n + 1
98 exe.cmd = exe.cmd .. l .. ' ; '
99 end
71 end 100 end
72 end 101 end
73 end 102 end