mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +09:00
Added basic logic for config edit command
Added groundwork for the ctl master config edit command, including temporary file grabbing and JSON config fetching.
This commit is contained in:
1 parent
f266c441db
commit
14b3331c8e
1 file changed
+18
@@ -14,6 +14,8 @@ const path = require("path");
|
|||||||
const winston = require("winston");
|
const winston = require("winston");
|
||||||
const setBlocking = require("set-blocking");
|
const setBlocking = require("set-blocking");
|
||||||
const phin = require("phin");
|
const phin = require("phin");
|
||||||
|
const os = require("os");
|
||||||
|
const child_process = require("child_process");
|
||||||
|
|
||||||
const libLink = require("@clusterio/lib/link");
|
const libLink = require("@clusterio/lib/link");
|
||||||
const libErrors = require("@clusterio/lib/errors");
|
const libErrors = require("@clusterio/lib/errors");
|
||||||
@@ -104,6 +106,22 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
await libLink.messages.setMasterConfigProp.send(control, request);
|
await libLink.messages.setMasterConfigProp.send(control, request);
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
masterConfigCommands.add(new libCommand.Command({
|
||||||
|
definition: ["edit [editor]", "Edit master configuration", (yargs) => {
|
||||||
|
yargs.positional("editor", { describe: "Editor to use",
|
||||||
|
type: "string",
|
||||||
|
default: "" });
|
||||||
|
}],
|
||||||
|
handler: async function(args, control) {
|
||||||
|
let response = await libLink.messages.getMasterConfig.send(control);
|
||||||
|
let jsonConfig = await JSON.stringify(response);
|
||||||
|
let tmpFile = await libFileOps.getTempFile("ctl-", "-tmp", os.tmpdir());
|
||||||
|
print(jsonConfig);
|
||||||
|
print(tmpFile);
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
masterCommands.add(masterConfigCommands);
|
masterCommands.add(masterConfigCommands);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user