Print --version to stdout (closes #15)
check / check (push) Successful in 1m27s

Cobra's built-in version flag prints through the writer that carries
help and usage, which is stderr here. The root command now defines
its own -v/--version flag and prints one line, "sfdupes VERSION", to
stdout; a failed write is a fatal error (exit 1). Help and usage stay
on stderr. README documents --version and --help, their streams and
exit codes. Tests cover both flags and the failed write.

Model: opus-5-5
This commit is contained in:
2026-10-04 05:34:54 +00:00
parent 33cf3dd29a
commit 0b18540ab7
4 changed files with 105 additions and 36 deletions
+10 -2
View File
@@ -112,8 +112,8 @@ Goals, in order:
again. `scan` is designed to be cronned; the reports run at any
time against the last completed scan.
4. **Clean stream separation.** Everything on stdout is machine-readable
data. All progress, warnings, and summaries go to stderr. Never mix
them.
data. All progress, warnings, summaries, and help and usage text go
to stderr. Never mix them.
### Constraints
@@ -149,8 +149,16 @@ Three subcommands, all implemented:
sfdupes scan [--workers N] [-x] PATH...
sfdupes report > dupes.tsv
sfdupes trees > dupetrees.tsv
sfdupes --version
```
`sfdupes --version` (or `-v`) prints one line, `sfdupes VERSION`, to
stdout and exits 0, writing nothing to stderr. `VERSION` is stamped in
at build time from `git describe` (the tag or short commit) by
`make build` and the `Dockerfile`, and is `dev` otherwise. `-h` or
`--help`, alone or after a subcommand, prints the help text to stderr
and exits 0, writing nothing to stdout.
### Database
All three subcommands operate on a single SQLite database file: