mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-26 00:33:12 +09:00
More work on command line tools #59
This commit is contained in:
1 parent
bd1304365c
commit
906b192683
3 files changed
+43
-7
No files matched your search
@@ -126,8 +126,14 @@ if (!command || command == "help" || command == "--help") {
|
|||||||
} else if (command == "manage"){
|
} else if (command == "manage"){
|
||||||
// console.log("Launching mod manager");
|
// console.log("Launching mod manager");
|
||||||
//const fullUsage = 'node client.js manage [instance, "shared"] ["mods", "config"] ...';
|
//const fullUsage = 'node client.js manage [instance, "shared"] ["mods", "config"] ...';
|
||||||
function usage(instance, tool){
|
function usage(instance, tool, action){
|
||||||
return 'node client.js manage '+(instance || '[instance, "shared"]') +' '+ (tool || '["mods", "config"]') + ' ...';
|
if(tool && tool == "mods"){
|
||||||
|
console.log('node client.js manage '+instance+' '+tool+' ["list", "search", "update"]');
|
||||||
|
} else if(tool && tool == "config") {
|
||||||
|
console.log('node client.js manage '+instance+' '+tool+' ["list", "edit"]');
|
||||||
|
} else {
|
||||||
|
console.log('node client.js manage '+(instance || '[instance, "shared"]') +' '+ (tool || '["mods", "config"]') + ' ...');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const modManagerUsage1 = 'node client.js manage ';
|
const modManagerUsage1 = 'node client.js manage ';
|
||||||
const modManagerUsage2 = ' mods ["list", "update"]';
|
const modManagerUsage2 = ' mods ["list", "update"]';
|
||||||
@@ -139,23 +145,25 @@ if (!command || command == "help" || command == "--help") {
|
|||||||
modManager.listMods(instance);
|
modManager.listMods(instance);
|
||||||
} else if(action == "search"){
|
} else if(action == "search"){
|
||||||
modManager.findMods(process.argv[6]);
|
modManager.findMods(process.argv[6]);
|
||||||
|
} else if(action == "update"){
|
||||||
|
modManager.updateAllMods();
|
||||||
} else {
|
} else {
|
||||||
console.log(modManagerUsage1 + instance + modManagerUsage2);
|
usage(instance, tool);
|
||||||
}
|
}
|
||||||
} else if(tool == "config"){
|
} else if(tool == "config"){
|
||||||
if(action == "list" || action == "show" || action == "display"){
|
if(action == "list" || action == "show" || action == "display"){
|
||||||
configManager.displayConfig(instance);
|
configManager.displayConfig(instance);
|
||||||
} else if(action == "edit"){
|
} else if(action == "edit"){
|
||||||
|
configManager.editConfig(instance, process.argv);
|
||||||
} else {
|
} else {
|
||||||
console.log()
|
usage(instance, tool);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(usage(instance));
|
usage(instance);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('Usage:');
|
console.log('Usage:');
|
||||||
console.log(usage(instance));
|
usage(instance);
|
||||||
}
|
}
|
||||||
// process.exit(1);
|
// process.exit(1);
|
||||||
} else if (command == "delete") {
|
} else if (command == "delete") {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
Provides tools for managing both masters and slaves config files.
|
||||||
|
@module configManager
|
||||||
|
*/
|
||||||
|
// require modules
|
||||||
|
const asTable = require("as-table").configure({delimiter: ' | '});
|
||||||
|
|
||||||
|
// internal requires
|
||||||
|
const config = require("./../../config");
|
||||||
|
/**
|
||||||
|
console.log()s each entry in the config
|
||||||
|
|
||||||
|
@param {string} instance Either undefined, "shared" or the instance to show the config for.
|
||||||
|
*/
|
||||||
|
module.exports.displayConfig = function(instance){
|
||||||
|
if(!instance || instance == "shared"){
|
||||||
|
let configArray = [];
|
||||||
|
Object.keys(config).forEach(key=>{
|
||||||
|
if(key != "__comment"){
|
||||||
|
if(typeof config[key] == "object"){
|
||||||
|
configArray.push({entry: key, value: JSON.stringify(config[key])});
|
||||||
|
} else configArray.push({entry: key, value: config[key]});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(asTable(configArray));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,6 +61,7 @@ module.exports.listMods = function(instance){
|
|||||||
token: config.token,
|
token: config.token,
|
||||||
require_ownership: false
|
require_ownership: false
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
console.log("Mods shared by all instances:")
|
||||||
factorioAPI.getInstalledMods().then(mods => {
|
factorioAPI.getInstalledMods().then(mods => {
|
||||||
console.log(asTable(mods));
|
console.log(asTable(mods));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user