({ positionals, flags, client })
| 12 | import type { ClientCommandHandler } from './router-types.ts'; |
| 13 | |
| 14 | export const screenshotCommand: ClientCommandHandler = async ({ positionals, flags, client }) => { |
| 15 | const result = (await runCliCommand({ |
| 16 | client, |
| 17 | command: 'screenshot', |
| 18 | positionals, |
| 19 | flags, |
| 20 | })) as CaptureScreenshotResult; |
| 21 | // A non-default responseLevel returns a leveled (digest) payload — overlayCount, |
| 22 | // artifacts, leveled overlayRefs. Rebuilding the default { path, overlayRefs } |
| 23 | // shape would drop those, so emit the leveled payload verbatim. |
| 24 | if (isNonDefaultResponseLevel(flags.responseLevel)) { |
| 25 | writeCommandOutput(flags, result, () => JSON.stringify(result, null, 2)); |
| 26 | return true; |
| 27 | } |
| 28 | const data = { |
| 29 | path: result.path, |
| 30 | ...(result.overlayRefs ? { overlayRefs: result.overlayRefs } : {}), |
| 31 | }; |
| 32 | writeCommandOutput(flags, data, () => |
| 33 | result.overlayRefs |
| 34 | ? `Annotated ${result.overlayRefs.length} refs onto ${result.path}` |
| 35 | : result.path, |
| 36 | ); |
| 37 | return true; |
| 38 | }; |
| 39 | |
| 40 | export const diffCommand: ClientCommandHandler = async ({ positionals, flags, client }) => { |
| 41 | if (positionals[0] === 'snapshot') { |
no test coverage detected