{"record":{"id":"727ff9e44f6fa9b8","repo":"pbakaus/impeccable","slug":"usage-comp-diff-mjs-comp-png-build-png","errorCode":null,"errorMessage":"usage: comp-diff.mjs --comp <png> --build <png> [--spec spec.json] [--out-dir dir] [--align top|stretch] [--label name] [--threshold 0.75] [--json]\n","messagePattern":"usage: comp-diff\\.mjs --comp <png> --build <png> \\[--spec spec\\.json\\] \\[--out-dir dir\\] \\[--align top\\|stretch\\] \\[--label name\\] \\[--threshold 0\\.75\\] \\[--json\\]\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/comp-verbs/src/comp_diff.rs","lineNumber":692,"sourceCode":"}\n\nfn resolve(io: &Io, p: &str) -> PathBuf {\n    let path = Path::new(p);\n    if path.is_absolute() {\n        path.to_path_buf()\n    } else {\n        io.cwd.join(path)\n    }\n}\n\n// ---- CLI -------------------------------------------------------------------\n\n/// `impeccable comp-diff --comp <png> --build <png> ...`\npub fn run(argv: &[String], io: &mut Io) -> i32 {\n    let comp_path = arg(argv, \"comp\");\n    let build_path = arg(argv, \"build\");\n    let (Some(comp_path), Some(build_path)) = (comp_path, build_path) else {\n        io.err(\"usage: comp-diff.mjs --comp <png> --build <png> [--spec spec.json] [--out-dir dir] [--align top|stretch] [--label name] [--threshold 0.75] [--json]\\n\");\n        return 1;\n    };\n    let comp = match read_png(io, comp_path) {\n        Ok(v) => v,\n        Err(e) => {\n            io.err(&format!(\"comp-diff: cannot read comp {comp_path}: {e}\\n\"));\n            return 1;\n        }\n    };\n    let build = match read_png(io, build_path) {\n        Ok(v) => v,\n        Err(e) => {\n            io.err(&format!(\"comp-diff: cannot read build {build_path}: {e}\\n\"));\n            return 1;\n        }\n    };\n    let mut spec: Option<Value> = None;\n    let spec_path = arg(argv, \"spec\");","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/comp-verbs/src/comp_diff.rs#L674-L710","documentation":"`comp-diff run` requires both `--comp <png>` and `--build <png>` arguments naming the reference and built screenshots to compare. If either is missing, it prints the full usage line to stderr and exits 1. This is argument validation before any file I/O happens.","triggerScenarios":"Calling `comp-diff` (binary or the run() entrypoint) with an empty argv, or omitting `--comp` and/or `--build`, or misspelling the flags so `arg()` returns None.","commonSituations":"Scripting the comparison step and forgetting one of the two images; a wrapper script builds the argv dynamically and drops an empty/failed variable; calling the legacy `.mjs` flags incorrectly after the move to the Rust binary.","solutions":["Pass both `--comp <png>` and `--build <png>` with paths to existing PNG files.","Check the invoking script for unset/empty variables feeding the flags.","Add optional flags (--spec, --out-dir, --align, --label, --threshold, --json) only after the two required ones."],"exampleFix":"// before\n$ impeccable comp-diff --build ./build.png\nusage: comp-diff.mjs --comp <png> --build <png> ...\n// after\n$ impeccable comp-diff --comp ./comp.png --build ./build.png","handlingStrategy":"validation","validationCode":"const args = parseArgs(argv);\nif (!args.comp || !args.build) {\n  console.error('comp-diff requires both --comp <png> and --build <png>');\n  process.exit(1);\n}","typeGuard":"function hasRequiredCompDiffArgs(a) {\n  return typeof a?.comp === 'string' && a.comp.length > 0 &&\n         typeof a?.build === 'string' && a.build.length > 0;\n}","tryCatchPattern":"const r = spawnSync('impeccable', ['comp-diff', '--comp', comp, '--build', build]);\nif (r.status === 1 && /usage: comp-diff/.test(r.stderr.toString())) {\n  console.error('Missing --comp or --build; see usage above.');\n}","preventionTips":["Assert both flags exist in any wrapper script before invoking comp-diff.","Fail fast in CI when a screenshot variable is empty.","Keep required flags first; optional flags are additive."],"tags":["cli","missing-argument","usage","image-comparison"],"backgroundTag":"missing-required-argument","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}