({
command,
positionals,
flags,
client,
debug,
replayTestReporterRuntime,
}: ClientCommandParams & { command: ClientBackedCliCommandName })
| 12 | import type { ClientCommandParams } from './router-types.ts'; |
| 13 | |
| 14 | export async function runGenericClientBackedCommand({ |
| 15 | command, |
| 16 | positionals, |
| 17 | flags, |
| 18 | client, |
| 19 | debug, |
| 20 | replayTestReporterRuntime, |
| 21 | }: ClientCommandParams & { command: ClientBackedCliCommandName }): Promise<boolean> { |
| 22 | const { result, cliOutput } = await runCliCommandWithOutput({ |
| 23 | client, |
| 24 | command: command as CommandName, |
| 25 | positionals, |
| 26 | flags, |
| 27 | }); |
| 28 | // A non-default responseLevel returns a leveled payload (e.g. the snapshot |
| 29 | // digest { nodeCount, refs }) that the per-command CLI formatters assume away — |
| 30 | // they serialize the default shape and drop the digest fields. Emit the leveled |
| 31 | // payload verbatim instead. |
| 32 | if (isNonDefaultResponseLevel(flags.responseLevel)) { |
| 33 | writeCommandOutput(flags, result, () => JSON.stringify(result, null, 2)); |
| 34 | return true; |
| 35 | } |
| 36 | if (cliOutput) { |
| 37 | writeCliOutput(flags, cliOutput); |
| 38 | } else { |
| 39 | const exitCode = await writeGenericCliOutput(command, flags, result, { |
| 40 | debug, |
| 41 | replayTestReporterRuntime, |
| 42 | }); |
| 43 | if (exitCode !== 0) { |
| 44 | process.exit(exitCode); |
| 45 | } |
| 46 | } |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | function writeGenericCliOutput( |
| 51 | command: ClientBackedCliCommandName, |
nothing calls this directly
no test coverage detected