Print help that was asked for to stdout (closes #179)
check / check (push) Successful in 1m50s

--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
This commit was merged in pull request #196.
This commit is contained in:
clawbot committed 2026-11-13 21:55:05 +01:00
1 parent e16c46804d
commit 523879bb0f
5 files changed
+202 -43

No files matched your search

+10 -8
View File
@@ -253,8 +253,9 @@ In order:
`trees` check only that each copy they name still exists, and leave out a
copy that is gone. `scan` is built to run from `cron`. The reports run at any
time, against what the database holds.
4. **Keep the streams apart.** Everything on stdout is machine-readable data.
Everything for a human reader, such as progress and warnings, goes to stderr.
4. **Keep the streams apart.** 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.
### Subcommands
@@ -324,12 +325,13 @@ The reference below is also the program's specification.
"Operands").
- `--version`, `-v` prints `sfdupes VERSION` (see "Install") to stdout and
exits 0. It writes nothing to stderr.
- `--help`, `-h`, alone or after a subcommand, prints the help text to stderr
and exits 0. It writes nothing to stdout. The help of `sfdupes` and of `scan`
names the database. The help of `report`, `trees`, `info` and `dwim` says what
each prints. `sfdupes scan --help` and `sfdupes dwim --help` also list the
default excludes of the system they run on, and the filesystem types the walk
never records anything on.
- `--help`, `-h`, alone or after a subcommand, prints the help text to stdout
and exits 0. It writes nothing to stderr. `sfdupes help` and
`sfdupes help COMMAND` do the same. The help of `sfdupes` and of `scan` names
the database. The help of `report`, `trees`, `info` and `dwim` says what each
prints. `sfdupes scan --help` and `sfdupes dwim --help` also list the default
excludes of the system they run on, and the filesystem types the walk never
records anything on.
### Duplicate detection