summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/args.test.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-25 11:27:43 +0900
committerAdam Malczewski <[email protected]>2026-06-25 11:27:43 +0900
commitc1bc7bfaaca7bdf4d9b2973f5dc88605217a7866 (patch)
tree204de76d526a052712bba0a97bfe8a5d8935ea64 /packages/cli/src/args.test.ts
parent59c481dc96aa40b8c8f0a81bb294a77d4e5aa533 (diff)
downloaddispatch-c1bc7bfaaca7bdf4d9b2973f5dc88605217a7866.tar.gz
dispatch-c1bc7bfaaca7bdf4d9b2973f5dc88605217a7866.zip
feat(cli): add --workspace filter to 'dispatch list'
The backend already supported GET /conversations?workspaceId= but the CLI never sent it. Wire the list command to that filter: - args.ts: parse --workspace / -w on 'list' (placed before the --catch-all so the single-dash -w shorthand isn't taken for a positional prefix); add workspaceId? to the list ParsedCommand. - http.ts: add workspaceId? to FetchConversationsOpts; send ?workspaceId= (after q/status, preserving URLSearchParams order). - main.ts: forward parsed.workspaceId into fetchConversations; update USAGE. Composable with --status and the <prefix> short-id arg. 'Open conversations in workspace X' is now: dispatch list --workspace X (status defaults to active,idle). No contract changes — purely additive CLI wiring. Tests: +4 args (incl. composability + missing-value error), +2 http (exact ?workspaceId= URL + combined status/workspaceId with %2C encoding). typecheck EXIT 0, biome clean (364 files), full suite 1558 passed. Live-verified against an isolated server.
Diffstat (limited to 'packages/cli/src/args.test.ts')
-rw-r--r--packages/cli/src/args.test.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/cli/src/args.test.ts b/packages/cli/src/args.test.ts
index 7a45c02..e613f31 100644
--- a/packages/cli/src/args.test.ts
+++ b/packages/cli/src/args.test.ts
@@ -254,6 +254,41 @@ describe("parseArgs", () => {
});
});
+ it("parses 'list' with --workspace", () => {
+ expect(parseArgs(["list", "--workspace", "proj"], { defaultServer })).toEqual({
+ kind: "list",
+ server: "http://localhost:24203",
+ workspaceId: "proj",
+ all: false,
+ });
+ });
+
+ it("parses 'list' with -w shorthand", () => {
+ const result = parseArgs(["list", "-w", "ws"], { defaultServer });
+ expect(result.kind).toBe("list");
+ if (result.kind === "list") expect(result.workspaceId).toBe("ws");
+ });
+
+ it("parses 'list' with --workspace, --status, and a prefix together", () => {
+ const result = parseArgs(["list", "abc", "--status", "active", "--workspace", "proj"], {
+ defaultServer,
+ });
+ expect(result).toEqual({
+ kind: "list",
+ server: "http://localhost:24203",
+ query: "abc",
+ status: "active",
+ workspaceId: "proj",
+ all: false,
+ });
+ });
+
+ it("errors when --workspace has no value (list)", () => {
+ const result = parseArgs(["list", "--workspace"], { defaultServer });
+ expect(result.kind).toBe("error");
+ if (result.kind === "error") expect(result.message).toContain("--workspace requires a value");
+ });
+
it("parses 'list' with --all", () => {
expect(parseArgs(["list", "--all"], { defaultServer })).toEqual({
kind: "list",