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

Function readWaitOptionsFromPositionals

src/commands/capture/wait.ts:78–106  ·  view source on GitHub ↗
(
  positionals: string[],
  flags: CliFlags,
)

Source from the content-addressed store, hash-verified

76}
77
78function readWaitOptionsFromPositionals(
79 positionals: string[],
80 flags: CliFlags,
81): WaitCommandOptions {
82 const parsed = parseWaitPositionals(positionals);
83 if (!parsed) {
84 throw new AppError(
85 'INVALID_ARGS',
86 'wait requires <ms>, text <text>, @ref, or <selector> [timeoutMs].',
87 );
88 }
89 const base = {
90 ...selectionOptionsFromFlags(flags),
91 ...selectorSnapshotOptionsFromFlags(flags),
92 };
93 if (parsed.kind === 'sleep') return { ...base, durationMs: parsed.durationMs };
94 if (parsed.kind === 'text') {
95 if (!parsed.text) throw new AppError('INVALID_ARGS', 'wait requires text.');
96 return { ...base, text: parsed.text, ...readTimeoutOption(parsed.timeoutMs) };
97 }
98 if (parsed.kind === 'ref') {
99 return { ...base, ref: parsed.rawRef, ...readTimeoutOption(parsed.timeoutMs) };
100 }
101 return {
102 ...base,
103 selector: parsed.selectorExpression,
104 ...readTimeoutOption(parsed.timeoutMs),
105 };
106}
107
108// fallow-ignore-next-line complexity
109function waitPositionals(options: WaitCommandOptions): string[] {

Callers 1

waitCliReaderFunction · 0.85

Calls 4

parseWaitPositionalsFunction · 0.90
readTimeoutOptionFunction · 0.85

Tested by

no test coverage detected