Print --version to stdout (closes #15) #78

Merged
clawbot merged 1 commits from issue-15-version-stdout into next 2026-10-04 09:47:29 +02:00
Collaborator

sfdupes --version now prints one line, sfdupes VERSION, to stdout, writes nothing to stderr, and exits 0. Help and usage stay on stderr. README documents -v/--version and -h/--help: what each prints, on which stream, and the exit code. Design goal 4 now lists help and usage text as stderr output.

How: cobra's built-in version flag prints through the same writer as help, and cobra also prints the usage text after an error through that writer. So it cannot be pointed at stdout without moving usage there too. The root command no longer sets cobra's Version. It defines its own -v/--version flag and prints the line through runE, so a failed stdout write is a fatal error (exit 1), the same as for report.

What the diff does not show:

  • sfdupes --version extra is now a usage error (exit 2). Cobra's flag printed the version and ignored the operand.
  • Item 2 and the image half of item 6 of the issue's definition of done moved to #67, which is already on next. Item 3 needed no change: the Makefile and Dockerfile embed only the version.

Disclosures:

  • Judgement call: kept the -v shorthand, which cobra's flag already provided, and documented it.
  • Judgement call: the line is sfdupes VERSION as the issue asks, replacing cobra's sfdupes version VERSION.

Model: opus-5-5

`sfdupes --version` now prints one line, `sfdupes VERSION`, to stdout, writes nothing to stderr, and exits 0. Help and usage stay on stderr. README documents `-v`/`--version` and `-h`/`--help`: what each prints, on which stream, and the exit code. Design goal 4 now lists help and usage text as stderr output. How: cobra's built-in version flag prints through the same writer as help, and cobra also prints the usage text after an error through that writer. So it cannot be pointed at stdout without moving usage there too. The root command no longer sets cobra's `Version`. It defines its own `-v`/`--version` flag and prints the line through `runE`, so a failed stdout write is a fatal error (exit 1), the same as for `report`. What the diff does not show: - `sfdupes --version extra` is now a usage error (exit 2). Cobra's flag printed the version and ignored the operand. - Item 2 and the image half of item 6 of the issue's definition of done moved to https://git.eeqj.de/sneak/sfdupes/issues/67, which is already on `next`. Item 3 needed no change: the `Makefile` and `Dockerfile` embed only the version. Disclosures: - Judgement call: kept the `-v` shorthand, which cobra's flag already provided, and documented it. - Judgement call: the line is `sfdupes VERSION` as the issue asks, replacing cobra's `sfdupes version VERSION`. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 07:36:50 +02:00
clawbot self-assigned this 2026-10-04 07:36:50 +02:00
Author
Collaborator
  • README.md, §Subcommands, the paragraph under the usage block: the sentence "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" is not true of the tree. Passing VERSION to make build, or as the Dockerfile's VERSION build argument, replaces the git describe value, so that build is neither. Also, away from a tag git describe gives the tag, a commit count and the short commit, not the tag alone or the short commit alone, and make build adds -dirty on a modified tree. Acceptable: describe the sources as the Makefile and Dockerfile apply them (a given VERSION first, otherwise git describe output, otherwise dev), or drop the sentence. The issue asks only what each flag prints, on which stream, and the exit code.

Model: opus-5-5

- `README.md`, §Subcommands, the paragraph under the usage block: the sentence "`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" is not true of the tree. Passing `VERSION` to `make build`, or as the `Dockerfile`'s `VERSION` build argument, replaces the `git describe` value, so that build is neither. Also, away from a tag `git describe` gives the tag, a commit count and the short commit, not the tag alone or the short commit alone, and `make build` adds `-dirty` on a modified tree. Acceptable: describe the sources as the `Makefile` and `Dockerfile` apply them (a given `VERSION` first, otherwise `git describe` output, otherwise `dev`), or drop the sentence. The issue asks only what each flag prints, on which stream, and the exit code. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 07:46:11 +02:00
clawbot force-pushed issue-15-version-stdout from 0b18540ab7 to 0fb7931ed2 2026-10-04 07:52:16 +02:00 Compare
Author
Collaborator
  • Dropped the sentence about where VERSION comes from; the paragraph now says only what --version and --help print, on which stream, and the exit code.

Model: opus-5-5

- Dropped the sentence about where `VERSION` comes from; the paragraph now says only what `--version` and `--help` print, on which stream, and the exit code. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 07:52:21 +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 09:30:50 +02:00
clawbot added 1 commit 2026-10-04 09:44:47 +02:00
Print --version to stdout (closes #15)
check / check (push) Waiting to run
53c621798f
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
clawbot force-pushed issue-15-version-stdout from 0fb7931ed2 to 53c621798f 2026-10-04 09:44:47 +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 09:44:52 +02:00
clawbot merged commit cb5dda4f45 into next 2026-10-04 09:47:29 +02:00
clawbot deleted branch issue-15-version-stdout 2026-10-04 09:47:30 +02:00
Sign in to join this conversation.