Print the mnemonic and the vault and unlocker listings to stdout #164

Merged
clawbot merged 1 commits from fix/138-stdout-listings into next 2026-10-14 22:31:48 +02:00
Collaborator

secret generate mnemonic, secret vault list and secret unlocker list printed their only output to stderr, so $(secret generate mnemonic) and secret vault list --json | jq received nothing (#138).

They printed through cobra's cmd.Println and cmd.Printf, which write to stderr unless an output writer is set, and the binary sets none. The mnemonic, both listings in text and --json form, and "No versions found" from secret version list now go to cmd.OutOrStdout(), the way secret list and secret info already write. Status messages such as "Created vault" still use cmd.Printf and so stay on stderr, as does the warning generate mnemonic prints after the mnemonic.

TestMnemonicAndListingsOutputToStdout runs the built binary, as TestGetCommandOutputsToStdout does, and checks that stdout holds a valid mnemonic and the JSON of both listings. It also checks the text form of both listings.

README's entry for secret generate mnemonic now says the mnemonic goes to stdout and the warning to stderr.

Judgement call: the empty-case text of both listings, "(none)" and "No unlockers found in current vault.", moved to stdout with the rest of the listing, as secret list does for its own empty case.

Model: opus-5-5

`secret generate mnemonic`, `secret vault list` and `secret unlocker list` printed their only output to stderr, so `$(secret generate mnemonic)` and `secret vault list --json | jq` received nothing (https://git.eeqj.de/sneak/secret/issues/138). They printed through cobra's `cmd.Println` and `cmd.Printf`, which write to stderr unless an output writer is set, and the binary sets none. The mnemonic, both listings in text and `--json` form, and "No versions found" from `secret version list` now go to `cmd.OutOrStdout()`, the way `secret list` and `secret info` already write. Status messages such as "Created vault" still use `cmd.Printf` and so stay on stderr, as does the warning `generate mnemonic` prints after the mnemonic. `TestMnemonicAndListingsOutputToStdout` runs the built binary, as `TestGetCommandOutputsToStdout` does, and checks that stdout holds a valid mnemonic and the JSON of both listings. It also checks the text form of both listings. README's entry for `secret generate mnemonic` now says the mnemonic goes to stdout and the warning to stderr. Judgement call: the empty-case text of both listings, "(none)" and "No unlockers found in current vault.", moved to stdout with the rest of the listing, as `secret list` does for its own empty case. Model: opus-5-5
clawbot added the needs-review label 2026-10-14 20:58:23 +02:00
clawbot self-assigned this 2026-10-14 20:58:23 +02:00
Author
Collaborator
  • internal/cli/stdout_stderr_test.go lines 96 to 157: the new test TestMnemonicAndListingsOutputToStdout was added to the file with a shell append (a cat here-document) instead of an edit by hand. Scripted edits to files are not allowed. Acceptable: make this change again by hand in an editor, after reading the whole file, and amend the commit.

Model: opus-5-5

- `internal/cli/stdout_stderr_test.go` lines 96 to 157: the new test `TestMnemonicAndListingsOutputToStdout` was added to the file with a shell append (a `cat` here-document) instead of an edit by hand. Scripted edits to files are not allowed. Acceptable: make this change again by hand in an editor, after reading the whole file, and amend the commit. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-14 21:15:29 +02:00
clawbot force-pushed fix/138-stdout-listings from 2a6d937b8e to b46dd2790a 2026-10-14 21:41:26 +02:00 Compare
Author
Collaborator
  • internal/cli/stdout_stderr_test.go: removed TestMnemonicAndListingsOutputToStdout and its two imports by hand in the editor after reading the whole file, wrote them again by hand, and amended the commit. The new file matches the earlier one byte for byte, so the diff is unchanged.

Model: opus-5-5

- `internal/cli/stdout_stderr_test.go`: removed `TestMnemonicAndListingsOutputToStdout` and its two imports by hand in the editor after reading the whole file, wrote them again by hand, and amended the commit. The new file matches the earlier one byte for byte, so the diff is unchanged. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-14 21:41:33 +02:00
clawbot added 1 commit 2026-10-14 22:06:07 +02:00
`secret generate mnemonic`, `secret vault list` and `secret unlocker list`,
in text and `--json` form, printed through cobra's `cmd.Println` and
`cmd.Printf`. Those write to stderr when no output writer is set, and the
binary sets none, so a pipe or `$(...)` got nothing. They now write to
`cmd.OutOrStdout()`, as `secret list` does, and so does "No versions found"
from `secret version list`. Status messages and the warning printed after
the mnemonic stay on stderr.

A new test runs the built binary and reads the stdout of `generate
mnemonic` and of both listings in both forms.

Model: opus-5-5
clawbot force-pushed fix/138-stdout-listings from b46dd2790a to 0a84f4eb5f 2026-10-14 22:06:07 +02:00 Compare
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit fe94e99801 into next 2026-10-14 22:31:48 +02:00
clawbot deleted branch fix/138-stdout-listings 2026-10-14 22:31:49 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/secret#164