feat: add events program

This commit is contained in:
Guillaume ARM 2026-06-07 21:55:17 +02:00
parent dff6af0666
commit efc7e88b9b
2 changed files with 48 additions and 0 deletions

View File

@ -9,6 +9,7 @@ local LIST_FILES = {
'servers/ping-server.lua',
-- programs
'programs/router.lua', -- router is not in servers folder because he's not ran on every machines
'programs/events.lua',
'programs/ping.lua',
'programs/upgrade.lua',
-- apis

47
programs/events.lua Normal file
View File

@ -0,0 +1,47 @@
local _VERSION = '1.0.0';
local command = ...;
local function printUsage()
print('events usage:');
print();
print('\t\t\tevents');
print('\t\t\tevents version');
print('\t\t\tevents help');
end
local function valueToString(value)
if type(value) == 'string' then
return value;
end
return textutils.serialize(value, { compact = true });
end
if command == 'version' or command == '-version' or command == '--version' then
print('events v' .. _VERSION);
return;
end
if command == 'help' or command == '-help' or command == '--help' then
printUsage();
return;
end
if command ~= nil and command ~= '' then
printUsage();
return;
end
print('Listening events... Press Ctrl+T to stop.');
while true do
local event = table.pack(os.pullEventRaw());
local parts = {};
for i = 1, event.n do
parts[i] = valueToString(event[i]);
end
print(table.concat(parts, ' '));
end