Skip to content

Commit

Permalink
chore: specify writer for version command
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Zantow <[email protected]>
  • Loading branch information
kzantow committed Nov 17, 2023
1 parent fa3e390 commit 1dbd041
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"runtime"

"github.com/iancoleman/strcase"
Expand All @@ -28,7 +29,7 @@ type runtimeInfo struct {

type versionAddition = func() (name string, value any)

func VersionCommand(id Identification, additions ...versionAddition) *cobra.Command {
func VersionCommand(id Identification, writer io.Writer, additions ...versionAddition) *cobra.Command {
var format string

cmd := &cobra.Command{
Expand All @@ -46,7 +47,7 @@ func VersionCommand(id Identification, additions ...versionAddition) *cobra.Comm

value, err := versionInfo(info, format, additions...)
if err == nil {
fmt.Print(value)
_, _ = writer.Write([]byte(value))
}
return err
},
Expand Down

0 comments on commit 1dbd041

Please sign in to comment.