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

Function parseReplayScriptLine

src/replay/script.ts:187–382  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

185
186// fallow-ignore-next-line complexity
187function parseReplayScriptLine(line: string): SessionAction | null {
188 const trimmed = line.trim();
189 if (trimmed.length === 0 || trimmed.startsWith('#')) return null;
190 const tokens = tokenizeReplayLine(trimmed);
191 const [command, ...args] = tokens;
192 if (command === undefined) return null;
193 if (command === 'context') return null;
194
195 const action: SessionAction = {
196 ts: Date.now(),
197 command,
198 positionals: [],
199 flags: {},
200 };
201
202 if (command === 'snapshot') {
203 action.positionals = [];
204 for (let index = 0; index < args.length; index += 1) {
205 const token = args[index];
206 if (token === '-i') {
207 action.flags.snapshotInteractiveOnly = true;
208 continue;
209 }
210 if (token === '-c') {
211 continue;
212 }
213 if (token === '--raw') {
214 action.flags.snapshotRaw = true;
215 continue;
216 }
217 if (token === '--force-full') {
218 action.flags.snapshotForceFull = true;
219 continue;
220 }
221 if ((token === '-d' || token === '--depth') && index + 1 < args.length) {
222 const parsedDepth = Number(args[index + 1]);
223 if (Number.isFinite(parsedDepth) && parsedDepth >= 0) {
224 action.flags.snapshotDepth = Math.floor(parsedDepth);
225 }
226 index += 1;
227 continue;
228 }
229 if ((token === '-s' || token === '--scope') && index + 1 < args.length) {
230 action.flags.snapshotScope = args[index + 1];
231 index += 1;
232 continue;
233 }
234 if (token === '--backend' && index + 1 < args.length) {
235 // Backward compatibility: ignore legacy snapshot backend token.
236 index += 1;
237 continue;
238 }
239 }
240 return action;
241 }
242
243 if (command === 'open') {
244 const parsed = parseReplayOpenFlags(args);

Callers 1

Calls 12

parseReplayOpenFlagsFunction · 0.90
parseReplayRuntimeFlagsFunction · 0.90
isClickLikeCommandFunction · 0.90
parseReplaySeriesFlagsFunction · 0.90
readScreenshotScriptFlagFunction · 0.90
isNumericTokenFunction · 0.85
hasFillTargetAndTextFunction · 0.85
startsWithMethod · 0.80
isFiniteMethod · 0.80
pushMethod · 0.80
tokenizeReplayLineFunction · 0.70

Tested by

no test coverage detected