mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
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.
This commit is contained in:
1 parent
14b3331c8e
commit
23d8a819af
1 file changed
+20
-3
+20
-3
@@ -115,10 +115,27 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
}],
|
}],
|
||||||
handler: async function(args, control) {
|
handler: async function(args, control) {
|
||||||
let response = await libLink.messages.getMasterConfig.send(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());
|
let tmpFile = await libFileOps.getTempFile("ctl-", "-tmp", os.tmpdir());
|
||||||
print(jsonConfig);
|
let done = 0;
|
||||||
print(tmpFile);
|
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");
|
||||||
|
});
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user