mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Experementing with the master config
no important work, commit for my own sake
This commit is contained in:
1 parent
f548ac2ecc
commit
0564eee400
1 file changed
+8
-15
+8
-15
@@ -115,9 +115,7 @@ 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 usefulData = response.serialized_config.groups[0]["fields"];
|
let usefulData = response.serialized_config;
|
||||||
print(response);
|
|
||||||
// We don't need a significant amount of the response
|
|
||||||
let tmpFile = await libFileOps.getTempFile("ctl-", "-tmp", os.tmpdir());
|
let tmpFile = await libFileOps.getTempFile("ctl-", "-tmp", os.tmpdir());
|
||||||
let editor = 0;
|
let editor = 0;
|
||||||
if (args.editor) {
|
if (args.editor) {
|
||||||
@@ -133,6 +131,8 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
print("No editor avalible to use. Checked CLI input, EDITOR env var and VISUAL env var");
|
print("No editor avalible to use. Checked CLI input, EDITOR env var and VISUAL env var");
|
||||||
exit(1); // TODO: exit gracefully apon no editor
|
exit(1); // TODO: exit gracefully apon no editor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <-- start process of running editor -->
|
// <-- start process of running editor -->
|
||||||
let editorSpawn = child_process.spawn(editor, [tmpFile], {
|
let editorSpawn = child_process.spawn(editor, [tmpFile], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
@@ -146,20 +146,13 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
exit(1); // TODO: exit gracefully apon error from editor
|
exit(1); // TODO: exit gracefully apon error from editor
|
||||||
});
|
});
|
||||||
// <-- end process of starting editor -->
|
// <-- end process of starting editor -->
|
||||||
|
|
||||||
|
|
||||||
editorSpawn.on("exit", (exit) => {
|
editorSpawn.on("exit", (exit) => {
|
||||||
|
let masterConfig = new libConfig.MasterConfig("control");
|
||||||
|
// eslint-disable-next-line
|
||||||
|
masterConfig.load(response);
|
||||||
// from here is when the edit exits, i.e. the user has quit
|
// from here is when the edit exits, i.e. the user has quit
|
||||||
let mg = libConfig.MasterGroup;
|
|
||||||
let config_definitions = mg._definitions;
|
|
||||||
let configElement = null;
|
|
||||||
let test_str = "";
|
|
||||||
for (configElement in usefulData) {
|
|
||||||
if (usefulData.hasOwnProperty(configElement)) {
|
|
||||||
let description = config_definitions.get(configElement).description;
|
|
||||||
let configElementValue = JSON.stringify(usefulData[configElement]);
|
|
||||||
test_str += `# ${description}\n${configElement} = ${configElementValue} \n\n`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print(test_str);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in new issue
Block a user