Skip to content

Validate command-line arguments and route diagnostics to stderr#19

Open
ssiddhantsharma wants to merge 1 commit into
whitehead:develfrom
ssiddhantsharma:input-validation-devel
Open

Validate command-line arguments and route diagnostics to stderr#19
ssiddhantsharma wants to merge 1 commit into
whitehead:develfrom
ssiddhantsharma:input-validation-devel

Conversation

@ssiddhantsharma

Copy link
Copy Markdown
Contributor

Targets devel. Small, self-contained CLI-robustness change that addresses the argument-parser TODOs in plaac.java (// should check for valid input here!).

No scoring behavior changesdevel’s MOT3 regression test stays byte-identical, and the versioning added in devel (-V / VERSION) is untouched.

What it fixes

Before (on devel) After
-a foo / -c foo → raw NumberFormatException stack trace, exit 0 clear usage error on stderr, exit 2
# skipping unknown option printed to stdout → mixed into the TSV routed to stderr
-i x.fa -p (value-flag with no value, last position) → silently runs summary mode stderr warning; the run still completes

All diagnostics now go to stderr, so stdout stays a clean TSV.

Tests

cli/tests/test_input_validation.sh covers all three fixes plus a valid-invocation sanity check, wired into cli-unit-test.yml as an extra step (so it runs on the existing Java 11 + 17 matrix). Verified locally: the MOT3 gold diff still passes and -V still prints the version.

Compatibility

build_plaac.sh still runs plaac.jar -i dummy to generate the web doc headers; that path is deliberately left non-fatal, so the build is unaffected. The web app builds its command with validated args and captures stderr separately, so the exit-code and stderr changes are compatible.

Targets the devel branch. Addresses the argument-parser TODOs in plaac.java
("should check for valid input here!") without changing any scoring behavior:
the branch's existing MOT3 regression test remains byte-identical, and the
versioning added in devel (-V / VERSION) is untouched.

- Non-numeric values for numeric options (-a, -c, -w, -W, -m) previously threw
  a raw NumberFormatException stack trace and exited 0. They now print a clear
  usage error to stderr and exit non-zero (parseIntArg/parseDoubleArg helpers).
- 'skipping unknown option' was printed to stdout, mixing a diagnostic into the
  TSV results; it now goes to stderr.
- A value-taking flag in the last position (e.g. a trailing '-p' with no
  print-list) was silently dropped, running plaac in an unintended mode. It now
  warns on stderr; the run still completes.

Diagnostics go to stderr throughout, so stdout stays a clean TSV.

Tests: cli/tests/test_input_validation.sh covers all three behaviors plus a
valid-invocation sanity check, added as a step to the cli-unit-test workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant