Skip to content

Commit f4fe814

Browse files
committed
Switch nwidger/jsoncolor to amterp/jsoncolor
I've forked the original because it appears unmaintained (unaddressed PR for 2+ years). Said PR is also exactly what I'm after. My fork undoes a broken commit and fixes what it aimed to fix correctly, and so by switching to it, we now have correctly-formatted colored JSON output in Rad, hurrah! You can see the now-correct formatting in the tests that are updated as part of this commit (as they will fail otherwise!).
1 parent 0f1b89d commit f4fe814

8 files changed

+54
-59
lines changed

core/func_print.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"strings"
66

7-
"github.com/nwidger/jsoncolor"
7+
"github.com/amterp/jsoncolor"
88
ts "github.com/tree-sitter/go-tree-sitter"
99
)
1010

core/testing/func_http_get_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ pprint(http_get(url))
1111
expected := `{
1212
"body": [
1313
{
14-
"id":1,
15-
"name":"Alice"
14+
"id": 1,
15+
"name": "Alice"
1616
},
1717
{
18-
"id":2,
19-
"name":"Bob"
18+
"id": 2,
19+
"name": "Bob"
2020
}
2121
],
22-
"duration_seconds":0,
23-
"status_code":200,
24-
"success":true
22+
"duration_seconds": 0,
23+
"status_code": 200,
24+
"success": true
2525
}
2626
`
2727
assertOutput(t, stdOutBuffer, expected)

core/testing/func_http_post_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ pprint(http_post(url))
1111
expected := `{
1212
"body": [
1313
{
14-
"id":1,
15-
"name":"Alice"
14+
"id": 1,
15+
"name": "Alice"
1616
},
1717
{
18-
"id":2,
19-
"name":"Bob"
18+
"id": 2,
19+
"name": "Bob"
2020
}
2121
],
22-
"duration_seconds":0,
23-
"status_code":200,
24-
"success":true
22+
"duration_seconds": 0,
23+
"status_code": 200,
24+
"success": true
2525
}
2626
`
2727
assertOutput(t, stdOutBuffer, expected)

core/testing/json_algo_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,32 +252,32 @@ pprint(node[0])
252252
{
253253
"friends": [
254254
{
255-
"id":2,
256-
"name":"Bob"
255+
"id": 2,
256+
"name": "Bob"
257257
}
258258
],
259-
"height":1.7,
260-
"id":1,
261-
"name":"Alice",
262-
"old":true
259+
"height": 1.7,
260+
"id": 1,
261+
"name": "Alice",
262+
"old": true
263263
},
264264
{
265265
"friends": [
266266
{
267-
"id":1,
268-
"name":"Alice"
267+
"id": 1,
268+
"name": "Alice"
269269
},
270270
{
271-
"height":"null",
272-
"id":3,
273-
"name":"Charlie"
271+
"height": "null",
272+
"id": 3,
273+
"name": "Charlie"
274274
},
275275
"null"
276276
],
277-
"height":1.8,
278-
"id":2,
279-
"name":"Bob",
280-
"old":false
277+
"height": 1.8,
278+
"id": 2,
279+
"name": "Bob",
280+
"old": false
281281
},
282282
"null"
283283
]

core/testing/print_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ request url:
3737
pprint(node[0])
3838
`
3939
expected := `{
40-
"age":30,
41-
"hometown":"New York"
40+
"age": 30,
41+
"hometown": "New York"
4242
}
4343
`
4444
setupAndRunCode(t, rsl, "--mock-response", ".*:./responses/unique_keys.json", "--color=never")
@@ -108,32 +108,32 @@ pprint(node[0])
108108
{
109109
"friends": [
110110
{
111-
"id":2,
112-
"name":"Bob"
111+
"id": 2,
112+
"name": "Bob"
113113
}
114114
],
115-
"height":1.7,
116-
"id":1,
117-
"name":"Alice",
118-
"old":true
115+
"height": 1.7,
116+
"id": 1,
117+
"name": "Alice",
118+
"old": true
119119
},
120120
{
121121
"friends": [
122122
{
123-
"id":1,
124-
"name":"Alice"
123+
"id": 1,
124+
"name": "Alice"
125125
},
126126
{
127-
"height":"null",
128-
"id":3,
129-
"name":"Charlie"
127+
"height": "null",
128+
"id": 3,
129+
"name": "Charlie"
130130
},
131131
"null"
132132
],
133-
"height":1.8,
134-
"id":2,
135-
"name":"Bob",
136-
"old":false
133+
"height": 1.8,
134+
"id": 2,
135+
"name": "Bob",
136+
"old": false
137137
},
138138
"null"
139139
]
@@ -167,8 +167,8 @@ a = { "alice": 35, "bob": "bar", "charlie": [1, "hi"] }
167167
pprint(a)
168168
`
169169
expected := `{
170-
"alice":35,
171-
"bob":"bar",
170+
"alice": 35,
171+
"bob": "bar",
172172
"charlie": [
173173
1,
174174
"hi"

core/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package core
22

33
const (
4-
Version = "0.5.26"
4+
Version = "0.5.27"
55
// todo add in commit hash somehow?
66
)

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ go 1.24.2
55
require (
66
github.com/amterp/color v1.20.0
77
github.com/amterp/go-tbl v0.9.0
8+
github.com/amterp/jsoncolor v0.4.0
89
github.com/amterp/rts v0.0.25
910
github.com/amterp/stid v1.1.1
1011
github.com/charmbracelet/huh v0.6.0
1112
github.com/dustin/go-humanize v1.0.1
1213
github.com/google/uuid v1.6.0
1314
github.com/lithammer/fuzzysearch v1.1.8
1415
github.com/mattn/go-isatty v0.0.20
15-
github.com/nwidger/jsoncolor v0.3.2
1616
github.com/samber/lo v1.47.0
1717
github.com/sanity-io/litter v1.5.6
1818
github.com/scylladb/go-set v1.0.2
@@ -57,3 +57,4 @@ require (
5757
//replace github.com/amterp/stid => ../stid
5858
//replace github.com/amterp/rts => ../rts
5959
//replace github.com/amterp/tree-sitter-rsl => ../tree-sitter-rsl
60+
//replace github.com/amterp/jsoncolor => ../jsoncolor

go.sum

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/amterp/color v1.20.0 h1:3qR8miQeGMfd++ExLt5xUdMWWYYwohdix6jLMSyXbWM=
44
github.com/amterp/color v1.20.0/go.mod h1:XRJ2OonPd9eRKRg6ddVJc6Yv/rvjzMhn+qdIDHKjE04=
55
github.com/amterp/go-tbl v0.9.0 h1:eh5bE1RbVKK6tN/FOjsotBNCF4+wvJSsH3HHw2t+Cb4=
66
github.com/amterp/go-tbl v0.9.0/go.mod h1:py0viOYEcyfO0Po/EdCW8Tgg7/LXecf6nBlqQFlrOZ8=
7+
github.com/amterp/jsoncolor v0.4.0 h1:X8QegRunhKC0HZ4PBQbUsSa5mfMqMIai9a3ipQbi+uc=
8+
github.com/amterp/jsoncolor v0.4.0/go.mod h1:/tXCJaCsrNNd8QpW/hqc0uz1yT2VzzaTbk9svkczlDM=
79
github.com/amterp/rts v0.0.25 h1:rS9MNMtnGljYYifMsJURgVNZ3Eg7LCoiBjUruw2xG3g=
810
github.com/amterp/rts v0.0.25/go.mod h1:KdJo3mS3PUBYxocZB7wmfWgPkPff01Xi3FSKZYb9ulY=
911
github.com/amterp/stid v1.1.1 h1:oNKQxgWm15Ra83mbrAGuPXYbQidjDFKCMx7W4KC4/Bc=
@@ -37,7 +39,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
3739
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
3840
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
3941
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
40-
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
4142
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
4243
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
4344
github.com/fatih/set v0.2.1 h1:nn2CaJyknWE/6txyUDGwysr3G5QC6xWB/PtVjPBbeaA=
@@ -48,12 +49,9 @@ github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8
4849
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
4950
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
5051
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
51-
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
5252
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
5353
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
5454
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
55-
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
56-
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
5755
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
5856
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
5957
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
@@ -72,8 +70,6 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU
7270
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
7371
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg=
7472
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ=
75-
github.com/nwidger/jsoncolor v0.3.2 h1:rVJJlwAWDJShnbTYOQ5RM7yTA20INyKXlJ/fg4JMhHQ=
76-
github.com/nwidger/jsoncolor v0.3.2/go.mod h1:Cs34umxLbJvgBMnVNVqhji9BhoT/N/KinHqZptQ7cf4=
7773
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7874
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7975
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -133,8 +129,6 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
133129
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
134130
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
135131
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
136-
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
137-
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
138132
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
139133
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
140134
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

0 commit comments

Comments
 (0)