MCPcopy Index your code
hub / github.com/callstack/agent-device / runGenericClientBackedCommand

Function runGenericClientBackedCommand

src/cli/commands/generic.ts:14–48  ·  view source on GitHub ↗
({
  command,
  positionals,
  flags,
  client,
  debug,
  replayTestReporterRuntime,
}: ClientCommandParams & { command: ClientBackedCliCommandName })

Source from the content-addressed store, hash-verified

12import type { ClientCommandParams } from './router-types.ts';
13
14export 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
50function writeGenericCliOutput(
51 command: ClientBackedCliCommandName,

Callers

nothing calls this directly

Calls 5

runCliCommandWithOutputFunction · 0.90
writeCommandOutputFunction · 0.90
writeCliOutputFunction · 0.85
writeGenericCliOutputFunction · 0.85

Tested by

no test coverage detected