trun

Script for parsing any output. Yes, it is all it does.
git clone git://gtms.dev/trun
Log | Files | Refs | README | LICENSE

handler_simple.lua (820B)


      1 -- Trun simple handler
      2 --
      3 -- interface
      4 -- - handle(userdata, line): return status
      5 -- - (optional) on_start(userdata): call once before start reading
      6 -- - (optional) on_update(userdata, line, status): calls every time when status changed
      7 -- - (optional) on_end(userdata): calls once after reading end
      8 --
      9 return {
     10   -- handle(userdata, line): return status
     11   handle = function(_, line)
     12     if line:find('success') then
     13       return 1
     14     elseif line:find('running') then
     15       return 0
     16     else
     17       return -1
     18     end
     19   end,
     20 
     21   -- on_update(userdata, line, status): calls every time when status changed
     22   on_update = function(_, _, status)
     23     if status == 1 or status == -1 then
     24       os.execute('notify-send "build finished"')
     25     end
     26 
     27     -- viz->examples/handler_functions.lua for examples functions to use.
     28   end,
     29 }