{"record":{"id":"28d068e902fe7423","repo":"affaan-m/ECC","slug":"unknown-option-arg","errorCode":null,"errorMessage":"Unknown option: ${arg}","messagePattern":"Unknown option: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/loop-status.js","lineNumber":121,"sourceCode":"      index += 1;\n    } else if (arg === '--now') {\n      options.now = readValue(args, index, arg);\n      index += 1;\n    } else if (arg === '--exit-code') {\n      options.exitCode = true;\n    } else if (arg === '--watch') {\n      options.watch = true;\n    } else if (arg === '--watch-count') {\n      options.watchCount = readPositiveInteger(readValue(args, index, arg), arg);\n      index += 1;\n    } else if (arg === '--watch-interval-seconds') {\n      options.watchIntervalSeconds = readPositiveNumber(readValue(args, index, arg), arg);\n      index += 1;\n    } else if (arg === '--write-dir') {\n      options.writeDir = readValue(args, index, arg);\n      index += 1;\n    } else {\n      throw new Error(`Unknown option: ${arg}`);\n    }\n  }\n\n  if (options.exitCode && options.watch && options.watchCount === null) {\n    throw new Error('--exit-code with --watch requires --watch-count so the process can exit');\n  }\n\n  return options;\n}\n\nfunction normalizeOptions(options = {}) {\n  return {\n    ...options,\n    bashTimeoutSeconds: options.bashTimeoutSeconds ?? DEFAULT_BASH_TIMEOUT_SECONDS,\n    exitCode: Boolean(options.exitCode),\n    limit: options.limit ?? DEFAULT_LIMIT,\n    transcriptPaths: options.transcriptPaths || [],\n    watch: Boolean(options.watch),","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/loop-status.js#L103-L139","documentation":"The loop-status.js parseArgs loop is an explicit if/else chain over a fixed flag set; the final else throws `Unknown option: <arg>` for anything unrecognized. Recognized flags are --help/-h, --json, --home, --transcript, --limit, --bash-timeout-seconds, --wake-grace-multiplier, --now, --exit-code, --watch, --watch-count, --watch-interval-seconds, --write-dir. Notably there is no shorthand and no positional handling.","triggerScenarios":"Typing a flag from a different script (--filter, --format). Using a hyphen variant like --watch_interval_seconds. Passing a positional path argument (the script only takes --transcript). A leading dash typo such as `-json`.","commonSituations":"Cross-contaminating flags between ECC scripts. Auto-complete inserting the wrong long option. Wrapper scripts forwarding unknown args via \"$@\".","solutions":["Run `node scripts/loop-status.js --help` and copy flag names exactly.","Pass transcript files via `--transcript <path>` (repeatable), not as bare positionals.","Strip unsupported args in wrapper scripts before forwarding."],"exampleFix":"# before\nnode scripts/loop-status.js --format json ~/.claude/projects/x/s.jsonl\n\n# after\nnode scripts/loop-status.js --json --transcript ~/.claude/projects/x/s.jsonl","handlingStrategy":"validation","validationCode":"const KNOWN = new Set(['--help','-h','--json','--home','--transcript','--limit','--bash-timeout-seconds','--wake-grace-multiplier','--now','--exit-code','--watch','--watch-count','--watch-interval-seconds','--write-dir']);\nfunction validateLoopStatusArgs(argv) {\n  for (const a of argv) { if (a.startsWith('-') && !KNOWN.has(a)) throw new Error(`Unknown option: ${a}`); }\n}","typeGuard":null,"tryCatchPattern":"try { parseArgs(process.argv); }\ncatch (err) { if (/Unknown option/.test(err.message)) { console.error(err.message); printHelp(2); } else throw err; }","preventionTips":["Keep a single source of truth for supported flags and surface it via --help.","Wrap invocations in a helper that filters unknown args.","Pass transcripts via --transcript, never as bare positionals."],"tags":["cli","argument-parsing","usage"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}