commit 360df3d3d850c0e39ee9c410bfedd2ef5722cd9b
parent ba72b740d57390327387f353924c97a127ec3255
Author: Tomas Nemec <nemi@skaut.cz>
Date: Tue, 8 Feb 2022 11:56:46 +0100
refactor: format
Diffstat:
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/trun.lua b/trun.lua
@@ -60,23 +60,17 @@ end
local userdata = {name = name}
-- status dir
-if not io.open(status_dir) then
- os.execute('mkdir ' .. status_dir)
-end
+if not io.open(status_dir) then os.execute('mkdir ' .. status_dir) end
-- status file
local status_file = status_dir .. '/' .. name .. '.' .. handler_name
local file = io.open(status_file, 'w')
-if not file then
- os.execute('touch ' .. status_file)
-end
+if not file then os.execute('touch ' .. status_file) end
-- cleanup removes status file and notify handlers.
local function cleanup()
os.execute('rm ' .. status_file)
- if handler.on_end then
- handler.on_end(userdata)
- end
+ if handler.on_end then handler.on_end(userdata) end
end
------------------------------------------------------------------------------
@@ -112,9 +106,7 @@ local function update_file(output)
file:close()
end
-if handler.on_start then
- handler.on_start(userdata)
-end
+if handler.on_start then handler.on_start(userdata) end
local lastStatus
for line in io.lines() do
@@ -122,11 +114,9 @@ for line in io.lines() do
status = handler.handle(userdata, line)
local status_test = handler.on_status_test or function(_, s, lastS) return s ~= lastS end
- if status and status_test(userdata, status,lastStatus) then
+ if status and status_test(userdata, status, lastStatus) then
update_file(status)
- if handler.on_update then
- handler.on_update(userdata, line, status)
- end
+ if handler.on_update then handler.on_update(userdata, line, status) end
end
end