feat: cube ls
This commit is contained in:
parent
f880a577a4
commit
12278f72e9
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.cuberc
|
||||||
|
.cubestartup
|
||||||
23
cube.lua
23
cube.lua
@ -1,4 +1,4 @@
|
|||||||
local _VERSION = '1.1.0';
|
local _VERSION = '1.2.0';
|
||||||
local CUBE_CHANNEL = 64;
|
local CUBE_CHANNEL = 64;
|
||||||
|
|
||||||
local net = require('/apis/net')();
|
local net = require('/apis/net')();
|
||||||
@ -132,14 +132,29 @@ local COMMANDS = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
ls = function()
|
ls = function()
|
||||||
print('TODO: ls');
|
local ok, results, packets = net.sendMultipleRequests(CUBE_CHANNEL, 'ping', 'ping');
|
||||||
|
|
||||||
|
if not ok then
|
||||||
|
error(results);
|
||||||
|
end
|
||||||
|
|
||||||
|
for k in ipairs(results) do
|
||||||
|
local result = results[k];
|
||||||
|
local packet = packets[k];
|
||||||
|
|
||||||
|
print("=> " .. tostring(packet.sourceId)
|
||||||
|
..
|
||||||
|
(
|
||||||
|
packet.sourceLabel and " (label=" .. tostring(packet.sourceLabel) .. ")" or
|
||||||
|
"") .. ": startup='" .. result.startup .. "'");
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
configure = function()
|
configure = function()
|
||||||
if not isConfigFileExists() then
|
if not isConfigFileExists() then
|
||||||
print('Error: unable to configure because \'.cuberc\' file is missing\nTry: \'cube init\' command')
|
print('Error: unable to configure because \'.cuberc\' file is missing\nTry: \'cube init\' command')
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
print('TODO: configure');
|
print('not implemented yet.');
|
||||||
end,
|
end,
|
||||||
["set-startup"] = function(machineId, shellCommand)
|
["set-startup"] = function(machineId, shellCommand)
|
||||||
if not isConfigFileExists() then
|
if not isConfigFileExists() then
|
||||||
@ -174,7 +189,7 @@ local COMMANDS = {
|
|||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
print('TODO: deploy.');
|
print('not implemented yet.');
|
||||||
end,
|
end,
|
||||||
version = function()
|
version = function()
|
||||||
print('cube client v' .. _VERSION);
|
print('cube client v' .. _VERSION);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
local _VERSION = '1.0.0';
|
local _VERSION = '1.1.0';
|
||||||
|
|
||||||
local function trim(s)
|
local function trim(s)
|
||||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||||
@ -17,7 +17,7 @@ local function readFile(path)
|
|||||||
return contents
|
return contents
|
||||||
end
|
end
|
||||||
|
|
||||||
local startupCommand = trim(readFile('.cubestartup') or "");
|
local startupCommand = trim(readFile('.cubestartup') or readFile('.cubestart') or "");
|
||||||
|
|
||||||
|
|
||||||
if startupCommand ~= "" then
|
if startupCommand ~= "" then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user