(line: string)
| 185 | |
| 186 | // fallow-ignore-next-line complexity |
| 187 | function 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); |
no test coverage detected