From 23d8a819af46db94f68979c9c8c281ffad720d1f Mon Sep 17 00:00:00 2001 From: jake87 Date: Tue, 26 Oct 2021 21:23:23 +1100 Subject: [PATCH] Added basic framework for edit command Implimented framework for edit command, including ability to get a temp file, open an editor on the file, then resume code execution once the editor exits. --- packages/ctl/ctl.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/ctl/ctl.js b/packages/ctl/ctl.js index 610fd352..0396fe26 100755 --- a/packages/ctl/ctl.js +++ b/packages/ctl/ctl.js @@ -115,10 +115,27 @@ masterConfigCommands.add(new libCommand.Command({ }], handler: async function(args, control) { let response = await libLink.messages.getMasterConfig.send(control); - let jsonConfig = await JSON.stringify(response); + let usefulData = response.serialized_config.groups[0]["fields"]; + let configJson = JSON.stringify(usefulData, null, "\t"); + /** + * Indent JSON with a tab for readability; these temp vars are simply + * for readability, they can be removed if wanted + */ let tmpFile = await libFileOps.getTempFile("ctl-", "-tmp", os.tmpdir()); - print(jsonConfig); - print(tmpFile); + let done = 0; + let editorSpawn = child_process.spawn("nvim", [tmpFile], { + stdio: "inherit", + detached: true, + }); + editorSpawn.on("data", (data) => { + process.stdout.pipe(data); + }); + editorSpawn.on("err", (err) => { + print(err); + }); + editorSpawn.on("exit", (exit) => { + print("veryline"); + }); }, }));