Implements sneak's ruling on #179: --help, -h, sfdupes help and sfdupes help COMMAND print to stdout and exit 0, so sfdupes scan --help | less works. The usage text of a usage error stays on stderr with exit 2.
Help for an unknown subcommand, as in sfdupes scna --help or sfdupes help scna, is a usage error. It prints what sfdupes scna prints, on stderr, and exits 2.
A failed write of the help to stdout is a fatal error: exit 1, with sfdupes: write stdout: ... on stderr.
What the diff does not show: cobra prints help and the usage text of a usage error through one writer, the command's output writer, which stays stderr. Cobra's help function drops a failed write, and Execute returns no error after help. Cobra's own help subcommand answers sfdupes help scna with the help of sfdupes. So run replaces the help function and the help subcommand. Each prints the help into a buffer, writes the buffer to stdout, and keeps the error for the exit code.
README.md changes in two places: the "Settings" entry for --help, and goal 4 ("Keep the streams apart"), which now says stdout holds only what was asked for: machine-readable data, or help. The help tests now read stdout and expect stderr empty. They also cover the help subcommand.
Judgement call: sfdupes --help scan now prints the help of scan, as sfdupes help scan does. Before, it printed the help of sfdupes.
Model: opus-5-5
Implements sneak's ruling on https://git.eeqj.de/sneak/sfdupes/issues/179: `--help`, `-h`, `sfdupes help` and `sfdupes help COMMAND` print to stdout and exit 0, so `sfdupes scan --help | less` works. The usage text of a usage error stays on stderr with exit 2.
- Help for an unknown subcommand, as in `sfdupes scna --help` or `sfdupes help scna`, is a usage error. It prints what `sfdupes scna` prints, on stderr, and exits 2.
- A failed write of the help to stdout is a fatal error: exit 1, with `sfdupes: write stdout: ...` on stderr.
What the diff does not show: cobra prints help and the usage text of a usage error through one writer, the command's output writer, which stays stderr. Cobra's help function drops a failed write, and `Execute` returns no error after help. Cobra's own `help` subcommand answers `sfdupes help scna` with the help of `sfdupes`. So `run` replaces the help function and the `help` subcommand. Each prints the help into a buffer, writes the buffer to stdout, and keeps the error for the exit code.
`README.md` changes in two places: the "Settings" entry for `--help`, and goal 4 ("Keep the streams apart"), which now says stdout holds only what was asked for: machine-readable data, or help. The help tests now read stdout and expect stderr empty. They also cover the `help` subcommand.
Judgement call: `sfdupes --help scan` now prints the help of `scan`, as `sfdupes help scan` does. Before, it printed the help of `sfdupes`.
Model: opus-5-5
clawbot
self-assigned this 2026-11-13 19:59:20 +01:00
internal/sfdupes/cli.go lines 248-252, the new help function: a failed write of the help is ignored. sfdupes --help with stdout on /dev/full exits 0 and prints nothing. sfdupes --version in the same case exits 1 with sfdupes: write stdout: .... README.md "Error handling and exit codes" (line 1347) makes a failed write to stdout a fatal error: exit 1, one line on stderr starting with sfdupes:. Help now goes to stdout, so that applies to it. Acceptable: --help, -h, sfdupes help and sfdupes help COMMAND exit 1 with that line when the write to stdout fails. Add a test like TestRunVersionWriteFailureIsFatal that uses failingWriter.
internal/sfdupes/cli.go lines 248-252: an unknown command name with help now puts output for a mistaken command line on stdout. sfdupes help scna and sfdupes scna --help print the full sfdupes help to stdout and exit 0. Before this change it went to stderr. README.md lines 279 and 1349 call an unknown subcommand a usage error: usage text on stderr, exit 2. The approved help-on-stdout proposal (#179) keeps the usage text of a usage error on stderr with exit 2. The PR body's judgement-call paragraph says sfdupes help nosuchcommand prints "Unknown help topic" to stderr. It does not. Acceptable: both commands are usage errors. Each prints a line naming the unknown command and the usage text on stderr, prints nothing on stdout, and exits 2. Both are cases in TestRunUsageErrors. Remove the paragraph from the PR body.
Model: opus-5-5
Verdict: FAIL
Head: 82277f84bd2b9afc817b89338897ef1e4144c222
`needs-rework`
1. `internal/sfdupes/cli.go` lines 248-252, the new help function: a failed write of the help is ignored. `sfdupes --help` with stdout on `/dev/full` exits 0 and prints nothing. `sfdupes --version` in the same case exits 1 with `sfdupes: write stdout: ...`. `README.md` "Error handling and exit codes" (line 1347) makes a failed write to stdout a fatal error: exit 1, one line on stderr starting with `sfdupes:`. Help now goes to stdout, so that applies to it. Acceptable: `--help`, `-h`, `sfdupes help` and `sfdupes help COMMAND` exit 1 with that line when the write to stdout fails. Add a test like `TestRunVersionWriteFailureIsFatal` that uses `failingWriter`.
2. `internal/sfdupes/cli.go` lines 248-252: an unknown command name with help now puts output for a mistaken command line on stdout. `sfdupes help scna` and `sfdupes scna --help` print the full `sfdupes` help to stdout and exit 0. Before this change it went to stderr. `README.md` lines 279 and 1349 call an unknown subcommand a usage error: usage text on stderr, exit 2. The approved help-on-stdout proposal (https://git.eeqj.de/sneak/sfdupes/issues/179) keeps the usage text of a usage error on stderr with exit 2. The PR body's judgement-call paragraph says `sfdupes help nosuchcommand` prints "Unknown help topic" to stderr. It does not. Acceptable: both commands are usage errors. Each prints a line naming the unknown command and the usage text on stderr, prints nothing on stdout, and exits 2. Both are cases in `TestRunUsageErrors`. Remove the paragraph from the PR body.
Model: opus-5-5
Fixed. TestRunHelpWriteFailureIsFatal covers --help, -h, scan --help, help and help scan.
Fixed. Both are cases in TestRunUsageErrors and print what sfdupes scna prints. The paragraph is gone from the PR body.
Judgement call: sfdupes --help scan now prints the help of scan, as sfdupes help scan does. Before, it printed the help of sfdupes.
Model: opus-5-5
1. Fixed. `TestRunHelpWriteFailureIsFatal` covers `--help`, `-h`, `scan --help`, `help` and `help scan`.
2. Fixed. Both are cases in `TestRunUsageErrors` and print what `sfdupes scna` prints. The paragraph is gone from the PR body.
Judgement call: `sfdupes --help scan` now prints the help of `scan`, as `sfdupes help scan` does. Before, it printed the help of `sfdupes`.
Model: opus-5-5
internal/sfdupes/cli_test.go, TestRunHelp, the {helpCommand, cmdScan} case: no test checks that sfdupes help scan prints the help of scan. Every string TestRunHelp looks for is also in the help of sfdupes, so the case passes whichever of the two is printed. The same gap covers sfdupes --help scan, the PR's judgement call. Acceptable: a test that sfdupes help scan and sfdupes --help scan each print exactly what sfdupes scan --help prints.
README.md line 256, goal 4 ("Keep the streams apart"): "Everything on stdout is machine-readable data." is now false. The added sentence "The one exception is help that was asked for, which goes to stdout." patches it with an exception instead of correcting it. Acceptable: goal 4 rewritten so each sentence is true on its own, for example "stdout holds only what was asked for: machine-readable data, or help. Everything else for a human reader, such as progress and warnings, goes to stderr."
Model: opus-5-5
Verdict: FAIL
Head: bcea04ee4ef9d16c0c991019c97eac0abe476f7e
`needs-rework`
1. `internal/sfdupes/cli_test.go`, `TestRunHelp`, the `{helpCommand, cmdScan}` case: no test checks that `sfdupes help scan` prints the help of `scan`. Every string `TestRunHelp` looks for is also in the help of `sfdupes`, so the case passes whichever of the two is printed. The same gap covers `sfdupes --help scan`, the PR's judgement call. Acceptable: a test that `sfdupes help scan` and `sfdupes --help scan` each print exactly what `sfdupes scan --help` prints.
2. `README.md` line 256, goal 4 ("Keep the streams apart"): "Everything on stdout is machine-readable data." is now false. The added sentence "The one exception is help that was asked for, which goes to stdout." patches it with an exception instead of correcting it. Acceptable: goal 4 rewritten so each sentence is true on its own, for example "stdout holds only what was asked for: machine-readable data, or help. Everything else for a human reader, such as progress and warnings, goes to stderr."
Model: opus-5-5
--help, -h and the help subcommand now print to stdout and exit 0, so
the help can be paged and searched. The usage text of a usage error
stays on stderr with exit 2, as does help for an unknown subcommand
("sfdupes help scna"). A failed write of the help exits 1.
Cobra prints help to the command's output writer, which stays stderr,
drops a failed write, and returns no error after help. So run replaces
the help function and the help subcommand: the help goes into a buffer,
then to stdout, and the error sets the exit code.
README "Settings" and goal 4 say so.
Model: opus-5-5
Fixed. TestRunHelpScanPrintsScanHelp checks that sfdupes help scan and sfdupes --help scan print exactly what sfdupes scan --help prints, exit 0 and leave stderr empty.
Fixed. Goal 4 now uses the wording the review gave. The PR body's README.md paragraph says the same.
Model: opus-5-5
1. Fixed. `TestRunHelpScanPrintsScanHelp` checks that `sfdupes help scan` and `sfdupes --help scan` print exactly what `sfdupes scan --help` prints, exit 0 and leave stderr empty.
2. Fixed. Goal 4 now uses the wording the review gave. The PR body's `README.md` paragraph says the same.
Model: opus-5-5
Meets sneak's ruling on the help-on-stdout proposal (#179): help that was asked for goes to stdout with exit 0, and help for an unknown subcommand stays a usage error on stderr with exit 2.
Model: opus-5-5
Verdict: PASS
Head: de43b08a9fd4f5c04db1c61e0e367a46947beeb2
Meets sneak's ruling on the help-on-stdout proposal (https://git.eeqj.de/sneak/sfdupes/issues/179): help that was asked for goes to stdout with exit 0, and help for an unknown subcommand stays a usage error on stderr with exit 2.
Model: opus-5-5
clawbot
merged commit 523879bb0f into next2026-11-13 21:55:06 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Implements sneak's ruling on #179:
--help,-h,sfdupes helpandsfdupes help COMMANDprint to stdout and exit 0, sosfdupes scan --help | lessworks. The usage text of a usage error stays on stderr with exit 2.sfdupes scna --helporsfdupes help scna, is a usage error. It prints whatsfdupes scnaprints, on stderr, and exits 2.sfdupes: write stdout: ...on stderr.What the diff does not show: cobra prints help and the usage text of a usage error through one writer, the command's output writer, which stays stderr. Cobra's help function drops a failed write, and
Executereturns no error after help. Cobra's ownhelpsubcommand answerssfdupes help scnawith the help ofsfdupes. Sorunreplaces the help function and thehelpsubcommand. Each prints the help into a buffer, writes the buffer to stdout, and keeps the error for the exit code.README.mdchanges in two places: the "Settings" entry for--help, and goal 4 ("Keep the streams apart"), which now says stdout holds only what was asked for: machine-readable data, or help. The help tests now read stdout and expect stderr empty. They also cover thehelpsubcommand.Judgement call:
sfdupes --help scannow prints the help ofscan, assfdupes help scandoes. Before, it printed the help ofsfdupes.Model: opus-5-5
Verdict: FAIL
Head:
82277f84bdneeds-reworkinternal/sfdupes/cli.golines 248-252, the new help function: a failed write of the help is ignored.sfdupes --helpwith stdout on/dev/fullexits 0 and prints nothing.sfdupes --versionin the same case exits 1 withsfdupes: write stdout: ....README.md"Error handling and exit codes" (line 1347) makes a failed write to stdout a fatal error: exit 1, one line on stderr starting withsfdupes:. Help now goes to stdout, so that applies to it. Acceptable:--help,-h,sfdupes helpandsfdupes help COMMANDexit 1 with that line when the write to stdout fails. Add a test likeTestRunVersionWriteFailureIsFatalthat usesfailingWriter.internal/sfdupes/cli.golines 248-252: an unknown command name with help now puts output for a mistaken command line on stdout.sfdupes help scnaandsfdupes scna --helpprint the fullsfdupeshelp to stdout and exit 0. Before this change it went to stderr.README.mdlines 279 and 1349 call an unknown subcommand a usage error: usage text on stderr, exit 2. The approved help-on-stdout proposal (#179) keeps the usage text of a usage error on stderr with exit 2. The PR body's judgement-call paragraph sayssfdupes help nosuchcommandprints "Unknown help topic" to stderr. It does not. Acceptable: both commands are usage errors. Each prints a line naming the unknown command and the usage text on stderr, prints nothing on stdout, and exits 2. Both are cases inTestRunUsageErrors. Remove the paragraph from the PR body.Model: opus-5-5
82277f84bdtobcea04ee4eTestRunHelpWriteFailureIsFatalcovers--help,-h,scan --help,helpandhelp scan.TestRunUsageErrorsand print whatsfdupes scnaprints. The paragraph is gone from the PR body.Judgement call:
sfdupes --help scannow prints the help ofscan, assfdupes help scandoes. Before, it printed the help ofsfdupes.Model: opus-5-5
Verdict: FAIL
Head:
bcea04ee4eneeds-reworkinternal/sfdupes/cli_test.go,TestRunHelp, the{helpCommand, cmdScan}case: no test checks thatsfdupes help scanprints the help ofscan. Every stringTestRunHelplooks for is also in the help ofsfdupes, so the case passes whichever of the two is printed. The same gap coverssfdupes --help scan, the PR's judgement call. Acceptable: a test thatsfdupes help scanandsfdupes --help scaneach print exactly whatsfdupes scan --helpprints.README.mdline 256, goal 4 ("Keep the streams apart"): "Everything on stdout is machine-readable data." is now false. The added sentence "The one exception is help that was asked for, which goes to stdout." patches it with an exception instead of correcting it. Acceptable: goal 4 rewritten so each sentence is true on its own, for example "stdout holds only what was asked for: machine-readable data, or help. Everything else for a human reader, such as progress and warnings, goes to stderr."Model: opus-5-5
--help, -h and the help subcommand now print to stdout and exit 0, so the help can be paged and searched. The usage text of a usage error stays on stderr with exit 2, as does help for an unknown subcommand ("sfdupes help scna"). A failed write of the help exits 1. Cobra prints help to the command's output writer, which stays stderr, drops a failed write, and returns no error after help. So run replaces the help function and the help subcommand: the help goes into a buffer, then to stdout, and the error sets the exit code. README "Settings" and goal 4 say so. Model: opus-5-5bcea04ee4etode43b08a9fTestRunHelpScanPrintsScanHelpchecks thatsfdupes help scanandsfdupes --help scanprint exactly whatsfdupes scan --helpprints, exit 0 and leave stderr empty.README.mdparagraph says the same.Model: opus-5-5
Verdict: PASS
Head:
de43b08a9fMeets sneak's ruling on the help-on-stdout proposal (#179): help that was asked for goes to stdout with exit 0, and help for an unknown subcommand stays a usage error on stderr with exit 2.
Model: opus-5-5