refactor(noteshrink): take input + output positional like the other subcommands #17

Merged
David merged 1 commit from refactor/noteshrink-single-file into main 2026-05-14 04:09:28 +02:00
Owner

noteshrink previously took N positional inputs plus --output-dir / --basename / --pdf / --global-palette / --no-sort, while every other subcommand follows the simpler <INPUT> <OUTPUT> shape. The mismatch tripped users up: monkey noteshrink in.png out.png silently treated "out.png" as a second input and wrote page0000.png and page0001.png into the current directory. The same flag soup also produced confusing clap errors when single-dash long flag names collided with the shorts that the multi-file flags brought along.

This change drops the multi-file mode entirely:

monkey noteshrink [OPTIONS] <INPUT> <OUTPUT>

Remaining flags: --value-threshold, --sat-threshold, --num-colors, --sample-fraction, --white-bg, --no-saturate, --quiet (with the existing short forms).

Removed:

  • CLI: --output-dir, --basename, --pdf, --global-palette, --no-sort.
  • Code: sort_filenames_numerically, build_global_palette, assemble_pdf, miniz_compress, and the related loop / outputs accumulator in run.

flate2 and lopdf stay in Cargo.toml because pdf::extract_images still uses them. Multi-page batch is now a shell loop:

for f in scan-*.png; do monkey noteshrink "$f" "out/$(basename "$f")"; done

PDF assembly was a thin convenience over per-page output and is gone for now; it can come back as its own subcommand later if it earns its keep.

Local checks pass: cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo build --all-targets, cargo test (39 passing, 2 ignored). End-to-end smoke test against a magick-generated input produced a correctly-quantised paletted PNG.

Test plan

  • Run monkey noteshrink scan.png out.png --num-colors 4 --white-bg on a real scan and confirm the output is reasonable.
  • Confirm monkey noteshrink --help shows only the new flag set.
  • Confirm the Forgejo Check workflow passes for this branch.
`noteshrink` previously took N positional inputs plus `--output-dir` / `--basename` / `--pdf` / `--global-palette` / `--no-sort`, while every other subcommand follows the simpler `<INPUT> <OUTPUT>` shape. The mismatch tripped users up: `monkey noteshrink in.png out.png` silently treated "out.png" as a second input and wrote `page0000.png` and `page0001.png` into the current directory. The same flag soup also produced confusing clap errors when single-dash long flag names collided with the shorts that the multi-file flags brought along. This change drops the multi-file mode entirely: ``` monkey noteshrink [OPTIONS] <INPUT> <OUTPUT> ``` Remaining flags: `--value-threshold`, `--sat-threshold`, `--num-colors`, `--sample-fraction`, `--white-bg`, `--no-saturate`, `--quiet` (with the existing short forms). Removed: - CLI: `--output-dir`, `--basename`, `--pdf`, `--global-palette`, `--no-sort`. - Code: `sort_filenames_numerically`, `build_global_palette`, `assemble_pdf`, `miniz_compress`, and the related loop / `outputs` accumulator in `run`. `flate2` and `lopdf` stay in `Cargo.toml` because `pdf::extract_images` still uses them. Multi-page batch is now a shell loop: ``` for f in scan-*.png; do monkey noteshrink "$f" "out/$(basename "$f")"; done ``` PDF assembly was a thin convenience over per-page output and is gone for now; it can come back as its own subcommand later if it earns its keep. Local checks pass: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo build --all-targets`, `cargo test` (39 passing, 2 ignored). End-to-end smoke test against a `magick`-generated input produced a correctly-quantised paletted PNG. ## Test plan - [ ] Run `monkey noteshrink scan.png out.png --num-colors 4 --white-bg` on a real scan and confirm the output is reasonable. - [ ] Confirm `monkey noteshrink --help` shows only the new flag set. - [ ] Confirm the Forgejo `Check` workflow passes for this branch.
refactor(noteshrink): take input + output positional like the other subcommands
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 17s
Create release / Create release from merged PR (pull_request) Has been skipped
999965b20f
`noteshrink` previously took N positional inputs plus `--output-dir` / `--basename` / `--pdf` / `--global-palette` / `--no-sort`, while `image`, `video`, and `pdf extract-images` followed the simpler `<INPUT> <OUTPUT>` shape. The mismatch tripped users up: a command like `monkey noteshrink in.png out.png` silently treated the "output" name as a second input and wrote `page0000.png` and `page0001.png` into the current directory. The clash also surfaced as confusing clap errors when single-dash long flags collided with the shorts that the multi-file flags brought along. This change drops the multi-file mode entirely: `noteshrink` now takes one input and one output, matching the rest of the CLI. The `--output-dir`, `--basename`, `--pdf`, `--global-palette`, and `--no-sort` flags are removed along with `sort_filenames_numerically`, `build_global_palette`, `assemble_pdf`, and `miniz_compress`. Multi-page workflows are still expressible as a shell loop; PDF assembly was always a thin convenience over per-page outputs and can be re-added later if it earns its keep. Both `flate2` and `lopdf` remain in `Cargo.toml` because `pdf::extract_images` still uses them.
David merged commit df389f4642 into main 2026-05-14 04:09:28 +02:00
David deleted branch refactor/noteshrink-single-file 2026-05-14 04:09:28 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/monkey!17
No description provided.