Skip to content

Commit 812f0e0

Browse files
sweetmantechclaude
andauthored
feat: add --account flag to orgs list and artists list (#6)
Allows admin/org keys to filter by a specific account_id, matching the API's existing account_id query param support. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 377f4a7 commit 812f0e0

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

__tests__/commands/artists.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ describe("artists list", () => {
5454
expect(get).toHaveBeenCalledWith("/api/artists", { org_id: "org-123" });
5555
});
5656

57+
it("passes account_id when --account is provided", async () => {
58+
vi.mocked(get).mockResolvedValue({
59+
status: "success",
60+
artists: [{ account_id: "a1", name: "Artist One", label: "Label A" }],
61+
});
62+
63+
await artistsCommand.parseAsync(["list", "--account", "acc-123"], {
64+
from: "user",
65+
});
66+
67+
expect(get).toHaveBeenCalledWith("/api/artists", { account_id: "acc-123" });
68+
});
69+
70+
it("combines --account and --org flags", async () => {
71+
vi.mocked(get).mockResolvedValue({
72+
status: "success",
73+
artists: [{ account_id: "a1", name: "Artist One", label: "Label A" }],
74+
});
75+
76+
await artistsCommand.parseAsync(["list", "--account", "acc-123", "--org", "org-456"], {
77+
from: "user",
78+
});
79+
80+
expect(get).toHaveBeenCalledWith("/api/artists", { account_id: "acc-123", org_id: "org-456" });
81+
});
82+
5783
it("prints JSON with --json flag", async () => {
5884
const artists = [{ account_id: "a1", name: "Artist One", label: "Label" }];
5985
vi.mocked(get).mockResolvedValue({ status: "success", artists });

__tests__/commands/orgs.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,23 @@ describe("orgs list", () => {
3636

3737
await orgsCommand.parseAsync(["list"], { from: "user" });
3838

39-
expect(get).toHaveBeenCalledWith("/api/organizations");
39+
expect(get).toHaveBeenCalledWith("/api/organizations", {});
4040
expect(logSpy).toHaveBeenCalledTimes(4); // header + separator + 2 rows
4141
});
4242

43+
it("passes account_id when --account is provided", async () => {
44+
vi.mocked(get).mockResolvedValue({
45+
status: "success",
46+
organizations: [{ organization_id: "org-1", organization_name: "My Org" }],
47+
});
48+
49+
await orgsCommand.parseAsync(["list", "--account", "acc-123"], {
50+
from: "user",
51+
});
52+
53+
expect(get).toHaveBeenCalledWith("/api/organizations", { account_id: "acc-123" });
54+
});
55+
4356
it("prints JSON with --json flag", async () => {
4457
const orgs = [{ organization_id: "org-1", organization_name: "My Org" }];
4558
vi.mocked(get).mockResolvedValue({

src/commands/artists.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ const listCommand = new Command("list")
66
.description("List artists for the current account")
77
.option("--json", "Output as JSON")
88
.option("--org <orgId>", "Filter by organization ID")
9+
.option("--account <accountId>", "Filter by account ID")
910
.action(async (opts) => {
1011
try {
1112
const params: Record<string, string> = {};
1213
if (opts.org) params.org_id = opts.org;
14+
if (opts.account) params.account_id = opts.account;
1315
const data = await get("/api/artists", params);
1416
const artists = (data.artists as Record<string, unknown>[]) || [];
1517

src/commands/orgs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import { printJson, printTable, printError } from "../output.js";
55
const listCommand = new Command("list")
66
.description("List organizations for the current account")
77
.option("--json", "Output as JSON")
8+
.option("--account <accountId>", "Filter by account ID")
89
.action(async (opts) => {
910
try {
10-
const data = await get("/api/organizations");
11+
const params: Record<string, string> = {};
12+
if (opts.account) params.account_id = opts.account;
13+
const data = await get("/api/organizations", params);
1114
const orgs = (data.organizations as Record<string, unknown>[]) || [];
1215

1316
if (opts.json) {

0 commit comments

Comments
 (0)