mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Reworked to use config list's grabber system
Also now using the system described by Hornwitser, in using libConfig.MasterConfig.groups to get definitions. Now all that's needed is to re-read the updated data back into clustorio.
This commit is contained in:
1 parent
08a8182173
commit
92814aa9b3
1 file changed
+16
-10
+16
-10
@@ -126,20 +126,26 @@ masterConfigCommands.add(new libCommand.Command({
|
||||
/* eslint-enable */
|
||||
// needed for the process.env statements to not be flagged by eslint
|
||||
} else {
|
||||
print();
|
||||
throw new libErrors.CommandError("No editor avalible. Checked CLI input, EDITOR and VISUAL env vars");
|
||||
}
|
||||
|
||||
async function afterEditorDone() {
|
||||
let MainConfig = new libConfig.MasterConfig("exampleonetwothree123");
|
||||
await MainConfig.load(response.serialized_config, "exampleonetwothree123");
|
||||
let groups = Array.from(libConfig.MasterConfig.groups.keys());
|
||||
// convert from MapIterator to array
|
||||
let mainConfigGroups = [];
|
||||
for (let i = 0; i < groups.length; i++) {
|
||||
mainConfigGroups[i] = MainConfig.group(groups[i]);
|
||||
let allConfigElements = "";
|
||||
for (let group of response.serialized_config.groups) {
|
||||
for (let [name, value] of Object.entries(group.fields)) {
|
||||
// needed for line lenght; IMO this is more readable then using a temp var
|
||||
// eslint-disable-next-line
|
||||
allConfigElements += `# ${libConfig.MasterConfig.groups.get(group.name)._definitions.get(name).description}\n`;
|
||||
allConfigElements += `${group.name}.${name} ${JSON.stringify(value)}\n\n`;
|
||||
}
|
||||
}
|
||||
print(allConfigElements);
|
||||
fs.writeFile(tmpFile, allConfigElements, (err) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
print(allConfigElements);
|
||||
async function afterEditorDone() {
|
||||
}
|
||||
|
||||
// <-- start process of running editor -->
|
||||
let editorSpawn = child_process.spawn(editor, [tmpFile], {
|
||||
|
||||
Reference in new issue
Block a user