( positionals: string[], flags: CliFlags, )
| 76 | } |
| 77 | |
| 78 | function 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 |
| 109 | function waitPositionals(options: WaitCommandOptions): string[] { |
no test coverage detected