From 14b3331c8ece2adf8b3358af01b6e521e87c9a49 Mon Sep 17 00:00:00 2001 From: jake87 Date: Tue, 26 Oct 2021 20:44:15 +1100 Subject: [PATCH] Added basic logic for config edit command Added groundwork for the ctl master config edit command, including temporary file grabbing and JSON config fetching. --- packages/ctl/ctl.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/ctl/ctl.js b/packages/ctl/ctl.js index ac01a274..610fd352 100755 --- a/packages/ctl/ctl.js +++ b/packages/ctl/ctl.js @@ -14,6 +14,8 @@ const path = require("path"); const winston = require("winston"); const setBlocking = require("set-blocking"); const phin = require("phin"); +const os = require("os"); +const child_process = require("child_process"); const libLink = require("@clusterio/lib/link"); const libErrors = require("@clusterio/lib/errors"); @@ -104,6 +106,22 @@ masterConfigCommands.add(new libCommand.Command({ 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);