mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +09:00
Cover ctl output paths and stop deleting fields before printing
user show, mod list, mod search and mod-pack list deleted fields off the received objects to trim the table, which made their toJSON throw in wire mode. They now pick the fields for the human table only and print the whole objects in json and wire mode. Add integration cases for config edit on the controller, a host and an instance, user show with instance stats, log query and host pending in human mode, mod-pack show with mods and settings, and wire output of the trimmed lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
23187859d6
commit
f49c633e77
5 files changed
+88
-55
No files matched your search
@@ -18,27 +18,18 @@ userCommands.add(new lib.Command({
|
||||
});
|
||||
}],
|
||||
handler: async function(args: { name: string, instanceStats: boolean }, ctl: Ctl) {
|
||||
let user = await ctl.send(new lib.UserGetRequest(args.name));
|
||||
Object.assign(user, user.playerStats);
|
||||
// @ts-expect-error Terrible hack
|
||||
delete user.playerStats;
|
||||
let instanceStats = user.instanceStats;
|
||||
// @ts-expect-error Terrible hack
|
||||
delete user.instanceStats;
|
||||
if (!args.instanceStats) {
|
||||
ctl.output.result(user, () => printProperties(user));
|
||||
return;
|
||||
}
|
||||
|
||||
let instances = await ctl.send(new lib.InstanceDetailsListRequest());
|
||||
const stats = [...instanceStats || []].map(([id, playerInstanceStats]) => ({
|
||||
id,
|
||||
name: instances.find(i => i.id === id)?.name ?? "<deleted>",
|
||||
stats: playerInstanceStats,
|
||||
}));
|
||||
ctl.output.result({ ...user, instanceStats: stats }, () => {
|
||||
printProperties(user);
|
||||
for (let { id, name, stats: playerInstanceStats } of stats) {
|
||||
const user = await ctl.send(new lib.UserGetRequest(args.name));
|
||||
const { playerStats, instanceStats, ...properties } = user;
|
||||
const instances = args.instanceStats && ctl.output.human
|
||||
? await ctl.send(new lib.InstanceDetailsListRequest())
|
||||
: [];
|
||||
ctl.output.result(user, () => {
|
||||
printProperties({ ...properties, ...playerStats });
|
||||
if (!args.instanceStats) {
|
||||
return;
|
||||
}
|
||||
for (let [id, playerInstanceStats] of instanceStats) {
|
||||
const name = instances.find(i => i.id === id)?.name ?? "<deleted>";
|
||||
print();
|
||||
print(`Instance ${name} (${id}):`);
|
||||
printProperties(playerInstanceStats);
|
||||
|
||||
Reference in new issue
Block a user