( interactor: Interactor, positionals: string[], context: DispatchContext | undefined, )
| 100 | } |
| 101 | |
| 102 | export async function handleFillCommand( |
| 103 | interactor: Interactor, |
| 104 | positionals: string[], |
| 105 | context: DispatchContext | undefined, |
| 106 | ): Promise<Record<string, unknown>> { |
| 107 | if (context?.directElementSelector) { |
| 108 | return await handleDirectElementSelectorFill( |
| 109 | interactor, |
| 110 | context.directElementSelector, |
| 111 | positionals, |
| 112 | context, |
| 113 | ); |
| 114 | } |
| 115 | |
| 116 | const x = Number(positionals[0]); |
| 117 | const y = Number(positionals[1]); |
| 118 | const text = positionals.slice(2).join(' '); |
| 119 | if (Number.isNaN(x) || Number.isNaN(y) || !text) { |
| 120 | throw new AppError('INVALID_ARGS', 'fill requires x y text'); |
| 121 | } |
| 122 | const delayMs = requireIntInRange(context?.delayMs ?? 0, 'delay-ms', 0, 10_000); |
| 123 | await interactor.fill(x, y, text, delayMs); |
| 124 | return { x, y, text, delayMs, ...successText(formatTextLengthMessage('Filled', text)) }; |
| 125 | } |
| 126 | |
| 127 | async function handleDirectElementSelectorFill( |
| 128 | interactor: Interactor, |
no test coverage detected