Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-taxis-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@upstash/box": patch
---

Bump version to trigger release workflow
5 changes: 5 additions & 0 deletions .changeset/icy-tables-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@upstash/box-cli": patch
---

Add header to list response
6 changes: 4 additions & 2 deletions packages/cli/src/__tests__/commands/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ describe("listCommand", () => {

await listCommand({ token: "key" });

expect(logSpy).toHaveBeenCalledWith(expect.stringContaining("box-1"));
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining("box-2"));
const calls = logSpy.mock.calls.map((c: unknown[]) => c[0]);
expect(calls[0]).toMatch(/^ID\s+STATUS\s+MODEL\s+CREATED/);
expect(calls[1]).toMatch(/^box-1\s+running\s+claude\s+2025-01-01/);
expect(calls[2]).toMatch(/^box-2\s+stopped\s+gpt\s+2025-01-02/);
});

it("prints message when empty", async () => {
Expand Down
15 changes: 13 additions & 2 deletions packages/cli/src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ export async function listCommand(flags: ListFlags): Promise<void> {
return;
}

for (const b of boxes) {
console.log(`${b.id}\t${b.status}\t${b.model}\t${b.created_at}`);
const headers = ["ID", "STATUS", "MODEL", "CREATED"];
const rows = boxes.map((b) => [b.id, b.status, b.model ?? "", String(b.created_at)]);

const colWidths = headers.map((h, i) =>
Math.max(h.length, ...rows.map((r) => r[i]!.length))
);

const formatRow = (row: string[]) =>
row.map((val, i) => val.padEnd(colWidths[i]!)).join(" ");

console.log(formatRow(headers));
for (const row of rows) {
console.log(formatRow(row));
}
}