feat: add programs directory in path
This commit is contained in:
parent
12278f72e9
commit
88ce07859d
19
install.lua
19
install.lua
@ -1,16 +1,26 @@
|
|||||||
local _VERSION = '1.0.0'
|
local _VERSION = '1.1.0'
|
||||||
|
|
||||||
local LIST_FILES = {
|
local LIST_FILES = {
|
||||||
|
-- startup
|
||||||
'startup/servers.lua',
|
'startup/servers.lua',
|
||||||
|
-- servers
|
||||||
'servers/ping-server.lua',
|
'servers/ping-server.lua',
|
||||||
'ping.lua',
|
'servers/cube-server.lua',
|
||||||
'router.lua',
|
'servers/cube-startup.lua',
|
||||||
|
-- programs
|
||||||
|
'programs/router.lua', -- router is not in servers folder because he's not ran on every machines
|
||||||
|
'programs/ping.lua',
|
||||||
|
'programs/cube.lua',
|
||||||
|
-- apis
|
||||||
'apis/net.lua',
|
'apis/net.lua',
|
||||||
'apis/eventloop.lua',
|
'apis/eventloop.lua',
|
||||||
};
|
};
|
||||||
|
|
||||||
-- remove old files
|
-- remove old files
|
||||||
fs.delete('ping-server.lua')
|
fs.delete('ping-server.lua');
|
||||||
|
fs.delete('ping.lua')
|
||||||
|
fs.delete('cube.lua')
|
||||||
|
fs.delete('router.lua')
|
||||||
|
|
||||||
local REPO_PREFIX = 'https://raw.githubusercontent.com/guillaumearm/cc-libs/master/'
|
local REPO_PREFIX = 'https://raw.githubusercontent.com/guillaumearm/cc-libs/master/'
|
||||||
|
|
||||||
@ -18,6 +28,7 @@ local previousDir = shell.dir()
|
|||||||
|
|
||||||
shell.setDir('/')
|
shell.setDir('/')
|
||||||
|
|
||||||
|
fs.makeDir('/programs');
|
||||||
fs.makeDir('/apis');
|
fs.makeDir('/apis');
|
||||||
fs.makeDir('/startup');
|
fs.makeDir('/startup');
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,38 @@ local net = require('/apis/net')();
|
|||||||
|
|
||||||
local cubeCommand, firstArg, secondArg = ...;
|
local cubeCommand, firstArg, secondArg = ...;
|
||||||
|
|
||||||
|
--- Pads str to length len with char from right
|
||||||
|
local leftPad = function(str, len, char)
|
||||||
|
if char == nil then char = ' ' end
|
||||||
|
local nbRepetition = len - #str;
|
||||||
|
|
||||||
|
if nbRepetition > 0 then
|
||||||
|
return str .. string.rep(char, len - #str)
|
||||||
|
end
|
||||||
|
|
||||||
|
return str;
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Pads str to length len with char from left
|
||||||
|
local rightPad = function(str, len, char)
|
||||||
|
if char == nil then char = ' ' end
|
||||||
|
local nbRepetition = len - #str;
|
||||||
|
|
||||||
|
if nbRepetition > 0 then
|
||||||
|
return string.rep(char, len - #str) .. str
|
||||||
|
end
|
||||||
|
|
||||||
|
return str;
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getRow(str1, str2, str3)
|
||||||
|
local row1 = leftPad(tostring(str1 or ''), 6, ' ')
|
||||||
|
local row2 = leftPad(tostring(str2 or ''), 16, ' ')
|
||||||
|
local row3 = leftPad(tostring(str3 or ''), 6, ' ')
|
||||||
|
|
||||||
|
return row1 .. row2 .. row3;
|
||||||
|
end
|
||||||
|
|
||||||
local function isFlag(name)
|
local function isFlag(name)
|
||||||
return function(arg)
|
return function(arg)
|
||||||
return arg == '-' .. name or arg == '--' .. name;
|
return arg == '-' .. name or arg == '--' .. name;
|
||||||
@ -138,15 +170,24 @@ local COMMANDS = {
|
|||||||
error(results);
|
error(results);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- print('ID LABEL\t\t\t\tSTARTUP');
|
||||||
|
print(getRow('ID', 'LABEL', 'STARTUP'))
|
||||||
|
|
||||||
for k in ipairs(results) do
|
for k in ipairs(results) do
|
||||||
local result = results[k];
|
local result = results[k];
|
||||||
local packet = packets[k];
|
local packet = packets[k];
|
||||||
|
|
||||||
print("=> " .. tostring(packet.sourceId)
|
|
||||||
..
|
-- local row1 = leftPad(tostring(packet.sourceId or ''), 8, ' ')
|
||||||
(
|
-- local row2 = leftPad(tostring(packet.sourceLabel or ''), 12, ' ')
|
||||||
packet.sourceLabel and " (label=" .. tostring(packet.sourceLabel) .. ")" or
|
-- local row3 = leftPad(tostring(result.startup or ''), 12, ' ')
|
||||||
"") .. ": startup='" .. result.startup .. "'");
|
-- print(packet.sourceId, packet.sourceLabel or '', result.startup)
|
||||||
|
print(getRow(packet.sourceId, packet.sourceLabel, result.startup))
|
||||||
|
-- print("=> " .. tostring(packet.sourceId)
|
||||||
|
-- ..
|
||||||
|
-- (
|
||||||
|
-- packet.sourceLabel and " (label=" .. tostring(packet.sourceLabel) .. ")" or
|
||||||
|
-- "") .. ": startup='" .. result.startup .. "'");
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
configure = function()
|
configure = function()
|
||||||
@ -6,6 +6,12 @@ local SERVERS = {
|
|||||||
"servers/cube-startup.lua",
|
"servers/cube-startup.lua",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
local function init()
|
||||||
|
shell.setPath(shell.path() .. ':/programs');
|
||||||
|
end
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
local periphEmulation = function()
|
local periphEmulation = function()
|
||||||
-- attach modem
|
-- attach modem
|
||||||
periphemu.create('top', 'modem');
|
periphemu.create('top', 'modem');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user