Skip to content

Commit

Permalink
fix: Don't rewrap JSON output (#332)
Browse files Browse the repository at this point in the history
This makes the output of `-o json` more similar to what the raw response
would be.
  • Loading branch information
avorima authored Aug 2, 2023
1 parent 223644f commit 36e3f82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 1 addition & 7 deletions pkg/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ func (p *JSONPrinter) write(out io.Writer, v interface{}) error {
return err
}
default:
var msg DefaultMsgPrint
msg.Message = v
err := WriteJSON(&msg, out)
err := WriteJSON(v, out)
if err != nil {
return err
}
Expand Down Expand Up @@ -181,10 +179,6 @@ func (p *TextPrinter) SetStderr(writer io.Writer) {
p.Stderr = writer
}

type DefaultMsgPrint struct {
Message interface{} `json:"Message,omitempty"`
}

type ToPrint struct {
Message string
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ func TestPrinterPrintStandardResultJson(t *testing.T) {
func TestPrinterPrintDefaultJson(t *testing.T) {
var (
b bytes.Buffer
str = `{
"Message": "command executed"
}`
str = `"command executed"`
)
viper.Set(constants.ArgOutput, "json")
viper.Set(constants.ArgServerUrl, constants.DefaultApiURL)
Expand Down

0 comments on commit 36e3f82

Please sign in to comment.