{"record":{"id":"840e80570b9c6c15","repo":"pbakaus/impeccable","slug":"target-value-missing","errorCode":"TARGET_VALUE_MISSING","errorMessage":"--target requires a path value.","messagePattern":"--target requires a path value\\.","errorType":"validation","errorClass":"TargetArgError","httpStatus":null,"severity":"error","filePath":"skill/scripts/lib/target-args.mjs","lineNumber":21,"sourceCode":"    super(message);\n    this.name = 'TargetArgError';\n    this.code = code;\n  }\n}\n\nexport function parseTargetPath(args = [], { strict = false } = {}) {\n  let targetPath = null;\n  for (let i = 0; i < args.length; i++) {\n    const arg = String(args[i]);\n    if (arg === '--target' || arg === '-t') {\n      const next = args[i + 1];\n      if (next && !String(next).startsWith('-')) {\n        targetPath = String(next);\n        i++;\n        continue;\n      }\n      if (strict) {\n        throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');\n      }\n      continue;\n    }\n    if (arg.startsWith('--target=')) {\n      const value = arg.slice('--target='.length);\n      if (value) {\n        targetPath = value;\n        continue;\n      }\n      if (strict) {\n        throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');\n      }\n    }\n  }\n  return targetPath;\n}\n\nexport function parseTargetOptions(args = [], options = {}) {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/pbakaus/impeccable/blob/f88b2837a7d7c3182e46307bbbb091a1ed547571/skill/scripts/lib/target-args.mjs#L3-L39","documentation":"Thrown by parseTargetPath in strict mode when --target/-t is followed by no value, or by another dash-prefixed token, or when --target= has an empty value. It is a TargetArgError carrying code TARGET_VALUE_MISSING (and name 'TargetArgError') so callers can distinguish it programmatically. In non-strict mode the same input is skipped silently and null is returned.","triggerScenarios":"`--target` as the last argument; `--target --mode local` (next token starts with '-', treated as a flag not a value); `--target=` with nothing after the equals; non-strict callers getting null and then failing downstream with a less specific error.","commonSituations":"Scripts building command lines from optional variables that are empty; flag reordering that puts a value-taking flag adjacent to another flag; users assuming --target defaults to the current directory.","solutions":["Give --target a value: `--target src/pages/index.astro`.","Use the attached form `--target=src/pages/index.astro`, which cannot be separated from its value.","Note that a value beginning with '-' (rare relative path) will be treated as a flag; prefix it as ./-weird or use the = form.","If invoking parseTargetPath programmatically in strict mode, catch TargetArgError and check err.code === 'TARGET_VALUE_MISSING'."],"exampleFix":"# before\nnode script.mjs --scope page --target\n\n# after\nnode script.mjs --scope page --target src/pages/index.astro\nnode script.mjs --scope page --target=src/pages/index.astro","handlingStrategy":"type-guard","validationCode":"function hasTargetValue(args) {\n  for (let i = 0; i < args.length; i++) {\n    const a = String(args[i]);\n    if ((a === '--target' || a === '-t') && !(args[i + 1] && !String(args[i + 1]).startsWith('-'))) return false;\n    if (a.startsWith('--target=') && !a.slice('--target='.length)) return false;\n  }\n  return true;\n}\nif (!hasTargetValue(argv)) { console.error('--target needs a value'); process.exit(2); }","typeGuard":"class TargetArgError extends Error {}\nfunction isTargetValueMissing(err) {\n  return err instanceof TargetArgError && err.code === 'TARGET_VALUE_MISSING';\n}","tryCatchPattern":"import { parseTargetPath } from './lib/target-args.mjs';\ntry {\n  const targetPath = parseTargetPath(argv, { strict: true });\n} catch (err) {\n  if (err.name === 'TargetArgError' && err.code === 'TARGET_VALUE_MISSING') {\n    console.error('usage: --target <path>  (or --target=<path>)');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Prefer the attached form --target=<path> in generated command lines — value and flag cannot separate.","Check that variables interpolated after --target are non-empty before spawning.","Catch TargetArgError by code when running parseTargetPath strict from library code."],"tags":["cli","missing-flag-value","target-args","strict-mode"],"backgroundTag":"missing-flag-value","analyzedSha":"f88b2837a7d7c3182e46307bbbb091a1ed547571","analyzedAt":"2026-08-18T04:58:36.608Z","contentChangedAt":"2026-08-18T04:58:36.608Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}