File tree Expand file tree Collapse file tree 4 files changed +11
-9
lines changed Expand file tree Collapse file tree 4 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ require (
77 github.com/onsi/ginkgo/v2 v2.17.1
88 github.com/onsi/gomega v1.30.0
99 github.com/spf13/cobra v1.8.0
10- kcl-lang.io/kcl-go v0.8.5
10+ kcl-lang.io/kcl-go v0.8.6-0.20240429200928-7db8b504239b
1111 kcl-lang.io/kcl-openapi v0.6.1
1212 kcl-lang.io/kcl-playground v0.5.1
1313 kcl-lang.io/kpm v0.8.5
Original file line number Diff line number Diff line change @@ -1735,8 +1735,8 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
17351735k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 /go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA =
17361736k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk =
17371737k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 /go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0 =
1738- kcl-lang.io/kcl-go v0.8.5 h1:YuaZju34cclGVB8Z1O1hhxZx6lYF4cW3x6yDqK6l3iI =
1739- kcl-lang.io/kcl-go v0.8.5 /go.mod h1:CkXBerH9YchN2mP7fTfq5DXdmhXHH2lrbg5TFVT4KL8 =
1738+ kcl-lang.io/kcl-go v0.8.6-0.20240429200928-7db8b504239b h1:MVb4qLIHdEcGRY1h84BpBlYSIBBADZO2JWAW0rz4RWI =
1739+ kcl-lang.io/kcl-go v0.8.6-0.20240429200928-7db8b504239b /go.mod h1:CkXBerH9YchN2mP7fTfq5DXdmhXHH2lrbg5TFVT4KL8 =
17401740kcl-lang.io/kcl-openapi v0.6.1 h1:iPH0EvPgDGZS5Lk00/Su5Av6AQP5IBG8f7gAUyevkHE =
17411741kcl-lang.io/kcl-openapi v0.6.1 /go.mod h1:Ai9mFztCVKkRSFabczO/r5hCNdqaNtAc2ZIRxTeV0Mk =
17421742kcl-lang.io/kcl-playground v0.5.1 h1:MKQQUHgt4+2QyU2NVwa73oksOaBJGDi4keGoggA0MiU =
Original file line number Diff line number Diff line change 33package options
44
55import (
6+ "bytes"
7+ "encoding/json"
68 "fmt"
79 "io"
810 "os"
@@ -205,12 +207,12 @@ func (o *RunOptions) writeResult(result *kcl.KCLResultList) error {
205207 }
206208 var output []byte
207209 if strings .ToLower (o .Format ) == Json {
208- // If we have multiple result, output the JSON array format, else output the single JSON object.
209- if result .Len () > 1 {
210- output = []byte (result .GetRawJsonResult () + "\n " )
211- } else {
212- output = []byte (result .First ().JSONString () + "\n " )
210+ var out bytes.Buffer
211+ err := json .Indent (& out , []byte (result .GetRawJsonResult ()), "" , " " )
212+ if err != nil {
213+ return err
213214 }
215+ output = []byte (out .String () + "\n " )
214216 } else {
215217 // Both considering the raw YAML format and the YAML stream format that contains the `---` separator.
216218 output = []byte (result .GetRawYamlResult () + "\n " )
Original file line number Diff line number Diff line change 5454 var buf2 bytes.Buffer
5555 options .Writer = & buf2
5656 options .Format = Json
57- options .SortKeys = false
57+ options .SortKeys = true
5858
5959 err = options .Run ()
6060 if err != nil {
You can’t perform that action at this time.
0 commit comments