Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cmd/invoke.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -194,8 +195,15 @@ func handleSdkError(err error) error {
func printResult(success bool, output string) {
var prettyJSON map[string]interface{}
if err := json.Unmarshal([]byte(output), &prettyJSON); err == nil {
bs, _ := json.MarshalIndent(prettyJSON, "", " ")
output = string(bs)
// Use a custom encoder to prevent escaping &, <, > as \u0026, \u003c, \u003e
// which breaks copy/paste of URLs in the invoke output.
var buf bytes.Buffer
encoder := json.NewEncoder(&buf)
encoder.SetEscapeHTML(false)
encoder.SetIndent("", " ")
if err := encoder.Encode(prettyJSON); err == nil {
output = strings.TrimSuffix(buf.String(), "\n")
}
}
// use pterm.Success if succeeded, pterm.Error if failed
if success {
Expand Down