Skip to content

Reject mixed package and file operands in pud fmt - #35

Open
Faizaanp wants to merge 1 commit into
puddi-lang:mainfrom
Faizaanp:fix/issue-10-fmt-mixed-operands
Open

Faizaanp wants to merge 1 commit into
puddi-lang:mainfrom
Faizaanp:fix/issue-10-fmt-mixed-operands

Conversation

@Faizaanp

@Faizaanp Faizaanp commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

pud fmt silently ignored extra operands: given a package directory followed by one or more .pud files (or two package directories), it formatted only the first package and ignored the rest. This change classifies the operands up front and rejects ambiguous combinations with a clear diagnostic before any file is written. The supported forms are unchanged.

What changed

  • src/main.rs - fmt_targets now splits positional arguments into .pud file operands and package operands. A mix of the two, or more than one package operand, returns an Err. run_fmt resolves fmt_targets before its write loop, so the error is reported via fail before any files are modified. The diagnostic states the expected forms: "pass either a single package directory or one or more .pud files".
  • tests/run.rs - added four regression tests using tiny temporary packages: mixed operands are rejected with the diagnostic and leave both files untouched; two package directories are rejected; a single package still formats and checks; multiple .pud files still format and check.
  • CHANGELOG.md - added a Fixed entry under [Unreleased] referencing Reject mixed package and file operands in pud fmt #10.

How verified

Reproduced on the unmodified code with the prebuilt debug binary: pud fmt <pkg> <extra.pud> exited 0, rewrote only the package's src/main.pud, and silently ignored extra.pud. pud fmt --check <pkg> and pud fmt --check <f1.pud> <f2.pud> worked as expected.

After the fix (binary built in this worktree):

  • pud fmt <pkg> <extra.pud> -> exit 1 with error: cannot mix a package directory with .pud files; pass either a single package directory or one or more .pud files; neither file modified.
  • pud fmt <pkg1> <pkg2> -> exit 1 with error: expected a single package directory; pass either a single package directory or one or more .pud files.
  • pud fmt --check <pkg> and pud fmt --check <f1.pud> <f2.pud> -> still report exactly the expected files.
  • cargo test --test run fmt_ -- --nocapture -> 4 passed, 0 failed.
  • cargo test -- --skip conformance_suite -> all passed (3 unit + 0 conformance + 9 integration). One run showed the unrelated timing-flaky plugin_host_capabilities test fail under parallel load; it passed 3/3 in isolation and the suite passed in full on rerun.

Regression tests

  • fmt_rejects_mixed_package_and_file_operands - mixed operands fail with the diagnostic and neither file is modified.
  • fmt_rejects_multiple_package_directories - two package operands fail with the diagnostic and neither package is modified.
  • fmt_accepts_single_package - single package still formats and passes --check.
  • fmt_accepts_multiple_files - multiple .pud files still format and pass --check.

Fixes #10

@ghfind-review ghfind-review Bot added the review: medium ghfind author score; see https://ghfind.com label Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: medium ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject mixed package and file operands in pud fmt

1 participant