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 net = require('/apis/net')();
|
||||
@ -132,14 +132,29 @@ local COMMANDS = {
|
||||
end
|
||||
end,
|
||||
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,
|
||||
configure = function()
|
||||
if not isConfigFileExists() then
|
||||
print('Error: unable to configure because \'.cuberc\' file is missing\nTry: \'cube init\' command')
|
||||
return;
|
||||
end
|
||||
print('TODO: configure');
|
||||
print('not implemented yet.');
|
||||
end,
|
||||
["set-startup"] = function(machineId, shellCommand)
|
||||
if not isConfigFileExists() then
|
||||
@ -174,7 +189,7 @@ local COMMANDS = {
|
||||
return;
|
||||
end
|
||||
|
||||
print('TODO: deploy.');
|
||||
print('not implemented yet.');
|
||||
end,
|
||||
version = function()
|
||||
print('cube client v' .. _VERSION);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
local _VERSION = '1.0.0';
|
||||
local _VERSION = '1.1.0';
|
||||
|
||||
local function trim(s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
@ -17,7 +17,7 @@ local function readFile(path)
|
||||
return contents
|
||||
end
|
||||
|
||||
local startupCommand = trim(readFile('.cubestartup') or "");
|
||||
local startupCommand = trim(readFile('.cubestartup') or readFile('.cubestart') or "");
|
||||
|
||||
|
||||
if startupCommand ~= "" then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user