@zaisma/cli 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/zaisma.mjs +14 -0
package/package.json
CHANGED
package/zaisma.mjs
CHANGED
|
@@ -207,6 +207,7 @@ const COMMANDS = {
|
|
|
207
207
|
"items remove": { about: "Remove an item nobody bought or was granted", arguments: [{ name: "slug" }, { name: "item_name" }], flags: {} },
|
|
208
208
|
"kept-rooms": { about: "A game's kept rooms (room.setKept), worlds that sleep with nobody in them: each one's code, name, size and when it was last played, and the game's storage", arguments: [{ name: "slug" }], flags: {} },
|
|
209
209
|
"kept-rooms delete": { about: "Delete a kept room's world for good; players in it are sent out", arguments: [{ name: "slug" }, { name: "room_code" }], flags: {} },
|
|
210
|
+
rooms: { about: "A game's live rooms on Zaisma, newest first: each one's code, name, labels, players and spectators, and whether it's kept", arguments: [{ name: "slug" }], flags: {} },
|
|
210
211
|
logs: {
|
|
211
212
|
about: "What a game's server printed on Zaisma in the last 30 days, oldest first: the newest lines, older ones with --cursor, or new ones as they come with --follow",
|
|
212
213
|
arguments: [{ name: "slug" }],
|
|
@@ -1932,6 +1933,18 @@ async function items(command, values) {
|
|
|
1932
1933
|
console.log(`Refund policy: ${answer.refund_policy === "own_words" ? answer.refund_policy_text : (answer.refund_policy ?? "none yet (set_purchase_settings), needed before anything goes on sale")}`);
|
|
1933
1934
|
}
|
|
1934
1935
|
|
|
1936
|
+
/** A game's live rooms (GET …/games/<slug>/rooms), as the MCP's list_rooms. */
|
|
1937
|
+
async function liveRooms(values) {
|
|
1938
|
+
const answer = await api("GET", `/games/${values.slug}/rooms`);
|
|
1939
|
+
if (isJson) return printJson(answer);
|
|
1940
|
+
if (!answer.rooms.length) console.log(`No live rooms on Zaisma right now.`);
|
|
1941
|
+
for (const room of answer.rooms) {
|
|
1942
|
+
const labels = Object.entries(room.labels).map(([labelName, labelValue]) => `${labelName}: ${labelValue}`).join(", ");
|
|
1943
|
+
console.log(`${room.room_code} ${(room.name ?? "").padEnd(24)} ${`${room.player_count}/${room.maximum_player_count}`.padStart(7)} players${room.spectator_count ? `, ${room.spectator_count} watching` : ""}${room.is_kept ? ", kept" : ""}${labels ? ` ${labels}` : ""}`);
|
|
1944
|
+
}
|
|
1945
|
+
if (answer.next_cursor) console.log(`${answer.room_count} rooms in all; --json, or list_rooms with cursor, gives the rest.`);
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1935
1948
|
/** A game's kept rooms (…/games/<slug>/kept-rooms…), as the MCP's list_kept_rooms and delete_kept_room. */
|
|
1936
1949
|
async function keptRooms(command, values) {
|
|
1937
1950
|
if (command === "kept-rooms") {
|
|
@@ -2168,6 +2181,7 @@ async function run({ command, values, flags, globalFlags, rest }) {
|
|
|
2168
2181
|
else if (command === "links" || command.startsWith("links ")) await links(command, values, flags);
|
|
2169
2182
|
else if (command === "secrets" || command.startsWith("secrets ")) await secrets(command, values);
|
|
2170
2183
|
else if (command === "items" || command.startsWith("items ")) await items(command, values);
|
|
2184
|
+
else if (command === "rooms") await liveRooms(values);
|
|
2171
2185
|
else if (command === "kept-rooms" || command.startsWith("kept-rooms ")) await keptRooms(command, values);
|
|
2172
2186
|
else if (command === "logs") await logs(values, flags);
|
|
2173
2187
|
else if (command === "database" || command.startsWith("database ")) await database(command, values, flags);
|