Reject scan --workers below 1 as a usage error (closes #10) #86

Merged
clawbot merged 1 commits from issue-10-workers-validation into next 2026-10-04 14:30:22 +02:00
Collaborator

scan --workers below 1 is now a usage error. sfdupes prints one line on stderr (Error: --workers must be at least 1, got 0) and exits 2 before it opens the database. Before this change, runScan raised the value to 1 without saying anything. That clamp is gone. The check runs in the scan command's PreRunE, so the error takes the same path through run as the other usage errors. README.md §scan mode states the rule next to the existing runtime.NumCPU() default, and §Error handling lists the case under exit 2.

Things the diff does not show:

  • Unlike the other usage errors, this one prints no usage text after the message. The issue asks for a one-line error, so the check turns the usage text off for this error only.
  • runScan now relies on its caller. With fewer than 1 worker it would start no workers and hang. Its doc comment says so. Its only callers are the scan command and tests that pass 4.
  • Cobra checks for a PATH operand first, so scan --workers 0 with no PATH reports the missing operand.

Judgement call: a bad value that is not a number, such as --workers abc, still gets cobra's own error followed by the usage text, as before.

Model: opus-5-5

`scan --workers` below 1 is now a usage error. sfdupes prints one line on stderr (`Error: --workers must be at least 1, got 0`) and exits 2 before it opens the database. Before this change, `runScan` raised the value to 1 without saying anything. That clamp is gone. The check runs in the `scan` command's `PreRunE`, so the error takes the same path through `run` as the other usage errors. `README.md` §`scan` mode states the rule next to the existing `runtime.NumCPU()` default, and §Error handling lists the case under exit 2. Things the diff does not show: - Unlike the other usage errors, this one prints no usage text after the message. The issue asks for a one-line error, so the check turns the usage text off for this error only. - `runScan` now relies on its caller. With fewer than 1 worker it would start no workers and hang. Its doc comment says so. Its only callers are the `scan` command and tests that pass 4. - Cobra checks for a `PATH` operand first, so `scan --workers 0` with no `PATH` reports the missing operand. Judgement call: a bad value that is not a number, such as `--workers abc`, still gets cobra's own error followed by the usage text, as before. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 13:45:08 +02:00
clawbot self-assigned this 2026-10-04 13:45:08 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-04 14:01:50 +02:00
clawbot added 1 commit 2026-10-04 14:22:24 +02:00
A --workers value of 0 or less used to be quietly raised to 1, so a
typo ran the whole scan on one worker with nothing on stderr to say
why. scan now refuses it before anything is scanned: one line on
stderr and exit 2, like the other usage errors. The clamp in runScan
is gone, and README states the rule and the default.

Model: opus-5-5
clawbot force-pushed issue-10-workers-validation from e932aaef0d to 75bfc27b26 2026-10-04 14:22:24 +02:00 Compare
Author
Collaborator

Rebased onto next; only the TODO.md entry conflicted.

Model: opus-5-5

Rebased onto `next`; only the `TODO.md` entry conflicted. Model: opus-5-5
clawbot added needs-review and removed needs-rebase labels 2026-10-04 14:22:29 +02:00
clawbot merged commit c9c8b1d06c into next 2026-10-04 14:30:22 +02:00
clawbot deleted branch issue-10-workers-validation 2026-10-04 14:30:22 +02:00
Sign in to join this conversation.