fix: remove unused init command

This commit is contained in:
Guillaume ARM 2022-07-18 23:08:08 +02:00
parent cd55d26f4e
commit 29ff10bf27

View File

@ -49,27 +49,9 @@ end
local isHelpFlag = isFlag('help'); local isHelpFlag = isFlag('help');
local isVersionFlag = isFlag('version'); local isVersionFlag = isFlag('version');
local function writeFile(path, content)
local file = fs.open(path, "w");
if not file then
return false;
end
file.write(content)
file.close();
return true;
end
local function isConfigFileExists()
return fs.exists('.cuberc');
end
local function printUsage() local function printUsage()
print('cube usage:') print('cube usage:')
print(); print();
print('\t\t\tcube init');
print('\t\t\tcube ls'); print('\t\t\tcube ls');
print('\t\t\tcube configure'); print('\t\t\tcube configure');
print('\t\t\tcube set-startup <machineId> [command]') print('\t\t\tcube set-startup <machineId> [command]')
@ -81,10 +63,6 @@ end
local function printUsageCommand(commandName) local function printUsageCommand(commandName)
local USAGES = { local USAGES = {
init = function()
print('\t\t\tcube init');
print('Init the master cube directory.')
end,
ls = function() ls = function()
print('\t\t\tcube ls'); print('\t\t\tcube ls');
print('Print all available cubes in the cluster.') print('Print all available cubes in the cluster.')
@ -130,11 +108,6 @@ if cubeCommand == nil or cubeCommand == '' or isHelpFlag(cubeCommand) then
end end
local rebootCommand = function(machineId) local rebootCommand = function(machineId)
if not isConfigFileExists() then
print('Error: unable to deploy because \'.cuberc\' file is missing\nTry: \'cube init\' command')
return;
end
if not machineId or machineId == '' then if not machineId or machineId == '' then
printUsageCommand('reboot'); printUsageCommand('reboot');
return; return;
@ -154,18 +127,6 @@ local rebootCommand = function(machineId)
end end
local COMMANDS = { local COMMANDS = {
init = function()
if isConfigFileExists() then
print('cube is already initialized.');
else
local ok = writeFile('.cuberc', '');
if ok then
print('.cuberc file created');
else
error('Cannot create .cuberc file');
end
end
end,
ls = function() ls = function()
local ok, results, packets = net.sendMultipleRequests(CUBE_CHANNEL, 'ping', 'ping'); local ok, results, packets = net.sendMultipleRequests(CUBE_CHANNEL, 'ping', 'ping');
@ -185,18 +146,9 @@ local COMMANDS = {
end end
end, end,
configure = function() configure = function()
if not isConfigFileExists() then
print('Error: unable to configure because \'.cuberc\' file is missing\nTry: \'cube init\' command')
return;
end
print('not implemented yet.'); print('not implemented yet.');
end, end,
["set-startup"] = function(machineId, shellCommand) ["set-startup"] = function(machineId, shellCommand)
if not isConfigFileExists() then
print('Error: unable to deploy because \'.cuberc\' file is missing\nTry: \'cube init\' command')
return;
end
if not machineId then if not machineId then
printUsageCommand('set-startup'); printUsageCommand('set-startup');
return; return;
@ -219,11 +171,6 @@ local COMMANDS = {
end, end,
reboot = rebootCommand, reboot = rebootCommand,
deploy = function() deploy = function()
if not isConfigFileExists() then
print('Error: unable to deploy because \'.cuberc\' file is missing\nTry: \'cube init\' command')
return;
end
print('not implemented yet.'); print('not implemented yet.');
end, end,
version = function() version = function()