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

Function parseReplaySeriesFlags

src/replay/script-utils.ts:189–244  ·  view source on GitHub ↗
(
  command: string,
  args: string[],
)

Source from the content-addressed store, hash-verified

187
188// fallow-ignore-next-line complexity
189export function parseReplaySeriesFlags(
190 command: string,
191 args: string[],
192): { positionals: string[]; flags: SessionAction['flags'] } {
193 const positionals: string[] = [];
194 const flags: SessionAction['flags'] = {};
195
196 const numericFlagMap = isClickLikeCommand(command)
197 ? CLICK_LIKE_NUMERIC_FLAG_MAP
198 : command === 'swipe'
199 ? SWIPE_NUMERIC_FLAG_MAP
200 : isTypingCommand(command)
201 ? TYPING_NUMERIC_FLAG_MAP
202 : undefined;
203
204 for (let index = 0; index < args.length; index += 1) {
205 const token = args[index]!;
206
207 if (isClickLikeCommand(command) && token === '--double-tap') {
208 flags.doubleTap = true;
209 continue;
210 }
211 const nextArg = args[index + 1];
212 if (isClickLikeCommand(command) && token === '--button' && nextArg !== undefined) {
213 const clickButton = nextArg;
214 if (clickButton === 'primary' || clickButton === 'secondary' || clickButton === 'middle') {
215 flags.clickButton = clickButton;
216 }
217 index += 1;
218 continue;
219 }
220
221 const numericKey = numericFlagMap?.get(token);
222 if (numericKey && nextArg !== undefined) {
223 const parsed = parseNonNegativeIntToken(nextArg);
224 if (parsed !== null) {
225 flags[numericKey] = parsed;
226 index += 1;
227 continue;
228 }
229 }
230
231 if (command === 'swipe' && token === '--pattern' && nextArg !== undefined) {
232 const pattern = nextArg;
233 if (pattern === 'one-way' || pattern === 'ping-pong') {
234 flags.pattern = pattern;
235 }
236 index += 1;
237 continue;
238 }
239
240 positionals.push(token);
241 }
242
243 return { positionals, flags };
244}
245
246// fallow-ignore-next-line complexity

Callers 1

parseReplayScriptLineFunction · 0.90

Calls 5

isClickLikeCommandFunction · 0.85
isTypingCommandFunction · 0.85
parseNonNegativeIntTokenFunction · 0.85
getMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…