import type { CorpConfig } from "../../core/config/types.js"; import type { createSealClient } from "../../core/http/factory.js"; import { runCapability } from "../helpers.js"; import { outputOptions } from "../printer.js"; import type { ParsedArgs } from "../types.js"; export async function handleContactsCommand( action: string | undefined, maybeName: string | undefined, client: Awaited>, corp: CorpConfig, args: ParsedArgs ) { if (action === "sync-time" || action === "last-sync-time") { await runCapability("sealContactsLastSyncTimeGet", client, corp, {}, outputOptions(args.options)); return; } if (action === "departments" || action === "department") { if (!maybeName) { await runCapability("sealContactsDepartmentsRootList", client, corp, {}, outputOptions(args.options)); return; } await runCapability("sealContactsDepartmentGet", client, corp, { departmentId: maybeName }, outputOptions(args.options)); return; } if (action === "children" || action === "department-children") { if (!maybeName) throw new Error("Usage: seal-use contacts children "); await runCapability("sealContactsDepartmentChildrenList", client, corp, { departmentId: maybeName }, outputOptions(args.options)); return; } if (action === "users" || action === "department-users") { if (!maybeName) throw new Error("Usage: seal-use contacts users "); await runCapability("sealContactsDepartmentUsersList", client, corp, { departmentId: maybeName }, outputOptions(args.options)); return; } throw new Error(`Unknown contacts command: ${action ?? ""}. Run 'seal-use help' for available commands.`); }