Fix 'secret get' to output to stdout instead of stderr

- Add Print method to CLI Instance that uses cmd.OutOrStdout()
- Update GetSecretWithVersion to use cli.Print instead of cmd.Print
- Add test to verify secret values go to stdout, not stderr
- Store command reference in Instance for proper output handling
This commit is contained in:
2025-07-29 20:01:10 +02:00
parent b301a414cb
commit 18fb79e971
3 changed files with 84 additions and 2 deletions

View File

@@ -2,6 +2,8 @@
package cli
import (
"fmt"
"git.eeqj.de/sneak/secret/internal/secret"
"github.com/spf13/afero"
"github.com/spf13/cobra"
@@ -57,3 +59,8 @@ func (cli *Instance) SetStateDir(stateDir string) {
func (cli *Instance) GetStateDir() string {
return cli.stateDir
}
// Print outputs to the command's configured output writer
func (cli *Instance) Print(a ...interface{}) (n int, err error) {
return fmt.Fprint(cli.cmd.OutOrStdout(), a...)
}