mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Rename Ctl's usage of "control" to "ctl" (#1039)
Ctl ended up calling its main class for "Control" for historical
reasons, along with its config file and plugin entrypoint.
The plugin entrypoint was renamed to ctl in 808eda0513. This
finishes that renaming by also renaming the main class, default config
file, config-control command, and main entrypoint.
The config-control command is renamed to config to be consistent with
the host and controller's config commands.
The term "control" is still kept in the config and message locations as
a common specifier for both ctl and web_ui.
This commit is contained in:
1 parent
1d1d9bb1c4
commit
5df5af7ca8
35 files changed
+383
-383
No files matched your search
@@ -5,7 +5,7 @@ import os from "os";
|
||||
import child_process from "child_process";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import type { Control } from "../ctl.js";
|
||||
import type { Ctl } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
import { serializedConfigToString, getEditor, configToKeyVal } from "./config_ops.js";
|
||||
|
||||
@@ -14,15 +14,15 @@ const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
export const controllerCommands = new lib.CommandTree({ name: "controller", description: "Controller management" });
|
||||
controllerCommands.add(new lib.Command({
|
||||
definition: ["stop", "Stop controller"],
|
||||
handler: async function(_args: object, control: Control) {
|
||||
await control.send(new lib.ControllerStopRequest());
|
||||
handler: async function(_args: object, ctl: Ctl) {
|
||||
await ctl.send(new lib.ControllerStopRequest());
|
||||
},
|
||||
}));
|
||||
|
||||
controllerCommands.add(new lib.Command({
|
||||
definition: ["restart", "Restart controller"],
|
||||
handler: async function(_args: object, control: Control) {
|
||||
await control.send(new lib.ControllerRestartRequest());
|
||||
handler: async function(_args: object, ctl: Ctl) {
|
||||
await ctl.send(new lib.ControllerRestartRequest());
|
||||
},
|
||||
}));
|
||||
controllerCommands.add(new lib.Command({
|
||||
@@ -30,14 +30,14 @@ controllerCommands.add(new lib.Command({
|
||||
yargs.option("restart", { alias: "r", type: "boolean", description: "Restart after update" });
|
||||
yargs.option("all", { alias: "a", type: "boolean", description: "Also update all plugins" });
|
||||
}],
|
||||
handler: async function(args: { restart: boolean, all: boolean }, control: Control) {
|
||||
handler: async function(args: { restart: boolean, all: boolean }, ctl: Ctl) {
|
||||
if (args.all) {
|
||||
await control.send(new lib.UpdateAllRequest());
|
||||
await ctl.send(new lib.UpdateAllRequest());
|
||||
} else {
|
||||
await control.send(new lib.ControllerUpdateRequest());
|
||||
await ctl.send(new lib.ControllerUpdateRequest());
|
||||
}
|
||||
if (args.restart) {
|
||||
await control.send(new lib.ControllerRestartRequest());
|
||||
await ctl.send(new lib.ControllerRestartRequest());
|
||||
} else {
|
||||
print("Controller updated; a restart is required to apply the changes.");
|
||||
}
|
||||
@@ -50,8 +50,8 @@ const controllerConfigCommands = new lib.CommandTree({
|
||||
|
||||
controllerConfigCommands.add(new lib.Command({
|
||||
definition: ["list", "List controller configuration"],
|
||||
handler: async function(args: object, control: Control) {
|
||||
let config = await control.send(new lib.ControllerConfigGetRequest());
|
||||
handler: async function(args: object, ctl: Ctl) {
|
||||
let config = await ctl.send(new lib.ControllerConfigGetRequest());
|
||||
|
||||
for (let [name, value] of Object.entries(config)) {
|
||||
print(`${name} ${JSON.stringify(value)}`);
|
||||
@@ -67,13 +67,13 @@ controllerConfigCommands.add(new lib.Command({
|
||||
"stdin": { describe: "read value from stdin", nargs: 0, type: "boolean" },
|
||||
});
|
||||
}],
|
||||
handler: async function(args: { field: string, value?: string, stdin?: boolean }, control: Control) {
|
||||
handler: async function(args: { field: string, value?: string, stdin?: boolean }, ctl: Ctl) {
|
||||
if (args.stdin) {
|
||||
args.value = (await lib.readStream(process.stdin)).toString().replace(/\r?\n$/, "");
|
||||
} else if (args.value === undefined) {
|
||||
args.value = "";
|
||||
}
|
||||
await control.send(new lib.ControllerConfigSetFieldRequest(args.field, args.value));
|
||||
await ctl.send(new lib.ControllerConfigSetFieldRequest(args.field, args.value));
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -86,7 +86,7 @@ controllerConfigCommands.add(new lib.Command({
|
||||
"stdin": { describe: "read value from stdin", nargs: 0, type: "boolean" },
|
||||
});
|
||||
}],
|
||||
handler: async function(args: { field: string, prop: string, value?: string, stdin?: boolean }, control: Control) {
|
||||
handler: async function(args: { field: string, prop: string, value?: string, stdin?: boolean }, ctl: Ctl) {
|
||||
if (args.stdin) {
|
||||
args.value = (await lib.readStream(process.stdin)).toString().replace(/\r?\n$/, "");
|
||||
}
|
||||
@@ -102,7 +102,7 @@ controllerConfigCommands.add(new lib.Command({
|
||||
}
|
||||
value = args.value;
|
||||
}
|
||||
await control.send(new lib.ControllerConfigSetPropRequest(args.field, args.prop, value));
|
||||
await ctl.send(new lib.ControllerConfigSetPropRequest(args.field, args.prop, value));
|
||||
},
|
||||
}));
|
||||
controllerConfigCommands.add(new lib.Command({
|
||||
@@ -113,8 +113,8 @@ controllerConfigCommands.add(new lib.Command({
|
||||
default: "",
|
||||
});
|
||||
}],
|
||||
handler: async function(args: { editor: string }, control: Control) {
|
||||
let config = await control.send(new lib.ControllerConfigGetRequest());
|
||||
handler: async function(args: { editor: string }, ctl: Ctl) {
|
||||
let config = await ctl.send(new lib.ControllerConfigGetRequest());
|
||||
let tmpFile = await lib.getTempFile("ctl-", "-tmp", os.tmpdir());
|
||||
let editor = await getEditor(args.editor);
|
||||
if (editor === undefined) {
|
||||
@@ -138,7 +138,7 @@ controllerConfigCommands.add(new lib.Command({
|
||||
for (let index in final) {
|
||||
if (index in final) {
|
||||
try {
|
||||
await control.send(new lib.ControllerConfigSetFieldRequest(
|
||||
await ctl.send(new lib.ControllerConfigSetFieldRequest(
|
||||
index,
|
||||
final[index],
|
||||
));
|
||||
@@ -167,8 +167,8 @@ const controllerPluginCommands = new lib.CommandTree({
|
||||
});
|
||||
controllerPluginCommands.add(new lib.Command({
|
||||
definition: ["list", "List plugins on controller"],
|
||||
handler: async function(args: object, control: Control) {
|
||||
let url = new URL(control.config.get("control.controller_url")!);
|
||||
handler: async function(args: object, ctl: Ctl) {
|
||||
let url = new URL(ctl.config.get("ctl.controller_url")!);
|
||||
url.pathname += "api/plugins";
|
||||
let response = await fetch(url);
|
||||
print(asTable(await response.json() as []));
|
||||
@@ -179,10 +179,10 @@ controllerPluginCommands.add(new lib.Command({
|
||||
yargs.positional("plugin", { describe: "Plugin to update", type: "string" });
|
||||
yargs.option("restart", { alias: "r", type: "boolean", description: "Restart after update" });
|
||||
}],
|
||||
handler: async function(args: { plugin: string, restart: boolean }, control: Control) {
|
||||
await control.sendTo("controller", new lib.PluginUpdateRequest(args.plugin));
|
||||
handler: async function(args: { plugin: string, restart: boolean }, ctl: Ctl) {
|
||||
await ctl.sendTo("controller", new lib.PluginUpdateRequest(args.plugin));
|
||||
if (args.restart) {
|
||||
await control.send(new lib.ControllerRestartRequest());
|
||||
await ctl.send(new lib.ControllerRestartRequest());
|
||||
} else {
|
||||
print("Plugin updated; a restart is required to apply the changes.");
|
||||
}
|
||||
@@ -193,10 +193,10 @@ controllerPluginCommands.add(new lib.Command({
|
||||
yargs.positional("plugin", { describe: "Plugin to install", type: "string" });
|
||||
yargs.option("restart", { alias: "r", type: "boolean", description: "Restart after update" });
|
||||
}],
|
||||
handler: async function(args: { plugin: string, restart: boolean }, control: Control) {
|
||||
await control.sendTo("controller", new lib.PluginInstallRequest(args.plugin));
|
||||
handler: async function(args: { plugin: string, restart: boolean }, ctl: Ctl) {
|
||||
await ctl.sendTo("controller", new lib.PluginInstallRequest(args.plugin));
|
||||
if (args.restart) {
|
||||
await control.send(new lib.ControllerRestartRequest());
|
||||
await ctl.send(new lib.ControllerRestartRequest());
|
||||
} else {
|
||||
print("Plugin installed; a restart is required to apply the changes.");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user