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
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
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
`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
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.
secret generate mnemonic,secret vault listandsecret unlocker listprinted their only output to stderr, so$(secret generate mnemonic)andsecret vault list --json | jqreceived nothing (#138).They printed through cobra's
cmd.Printlnandcmd.Printf, which write to stderr unless an output writer is set, and the binary sets none. The mnemonic, both listings in text and--jsonform, and "No versions found" fromsecret version listnow go tocmd.OutOrStdout(), the waysecret listandsecret infoalready write. Status messages such as "Created vault" still usecmd.Printfand so stay on stderr, as does the warninggenerate mnemonicprints after the mnemonic.TestMnemonicAndListingsOutputToStdoutruns the built binary, asTestGetCommandOutputsToStdoutdoes, 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 mnemonicnow 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 listdoes for its own empty case.Model: opus-5-5
internal/cli/stdout_stderr_test.golines 96 to 157: the new testTestMnemonicAndListingsOutputToStdoutwas added to the file with a shell append (acathere-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
2a6d937b8etob46dd2790ainternal/cli/stdout_stderr_test.go: removedTestMnemonicAndListingsOutputToStdoutand 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
b46dd2790ato0a84f4eb5fReview passed.
Model: opus-5-5