Skip to content

Commit 3670764

Browse files
committed
Formatting and updating readline to latest
1 parent 9c9498c commit 3670764

File tree

7 files changed

+45
-41
lines changed

7 files changed

+45
-41
lines changed

completer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (c *Console) complete(line []rune, pos int) readline.Completions {
5656

5757
// Assign both completions and command/flags/args usage strings.
5858
comps := readline.CompleteRaw(raw)
59-
comps = comps.Usage(completions.Usage)
59+
comps = comps.Usage("%s", completions.Usage)
6060
comps = c.justifyCommandComps(comps)
6161

6262
// If any errors arose from the completion call itself.
@@ -251,8 +251,10 @@ func splitCompWords(input string) (words []string, remainder string, err error)
251251
if len(next) == 0 {
252252
remainder = string(escapeChar)
253253
err = errUnterminatedEscape
254-
return
254+
255+
return words, remainder, err
255256
}
257+
256258
c2, l2 := utf8.DecodeRuneInString(next)
257259
if c2 == '\n' {
258260
input = next[l2:]
@@ -261,6 +263,7 @@ func splitCompWords(input string) (words []string, remainder string, err error)
261263
}
262264

263265
var word string
266+
264267
word, input, err = splitCompWord(input, &buf)
265268
if err != nil {
266269
return words, word + input, err

console.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func New(app string) *Console {
106106

107107
// Defaults
108108
console.EmptyChars = []rune{' ', '\t'}
109+
109110
return console
110111
}
111112

errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func (e Err) Error() string {
5656
if len(e.message) > 0 {
5757
return fmt.Sprintf("%s: %s", e.message, e.err.Error())
5858
}
59+
5960
return e.err.Error()
6061
}
6162

go.mod

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
module github.com/reeflective/console
22

3-
go 1.21
3+
go 1.23.6
44

55
require (
66
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
7-
github.com/reeflective/readline v1.0.15
7+
github.com/reeflective/readline v1.1.1
88
github.com/rsteube/carapace v0.46.3-0.20231214181515-27e49f3c3b69
99
github.com/spf13/cobra v1.8.1
10-
github.com/spf13/pflag v1.0.5
11-
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
10+
github.com/spf13/pflag v1.0.6
11+
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
1212
mvdan.cc/sh/v3 v3.7.0
1313
)
1414

1515
require (
16-
github.com/carapace-sh/carapace v1.1.3 // indirect
17-
github.com/carapace-sh/carapace-shlex v1.0.1 // indirect
1816
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1917
github.com/rivo/uniseg v0.4.7 // indirect
2018
github.com/rsteube/carapace-shlex v0.1.1 // indirect
21-
golang.org/x/sys v0.24.0 // indirect
22-
golang.org/x/term v0.23.0 // indirect
19+
golang.org/x/sys v0.30.0 // indirect
20+
golang.org/x/term v0.29.0 // indirect
2321
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
2422
gopkg.in/yaml.v3 v3.0.1 // indirect
2523
)

go.sum

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
github.com/carapace-sh/carapace v1.1.3 h1:EpkXrD7+I8TpvdnwGCrPnaDTS24dO514dyUiG+8QCj4=
2-
github.com/carapace-sh/carapace v1.1.3/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs=
3-
github.com/carapace-sh/carapace-shlex v1.0.1 h1:ww0JCgWpOVuqWG7k3724pJ18Lq8gh5pHQs9j3ojUs1c=
4-
github.com/carapace-sh/carapace-shlex v1.0.1/go.mod h1:lJ4ZsdxytE0wHJ8Ta9S7Qq0XpjgjU0mdfCqiI2FHx7M=
51
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
62
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
73
github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA=
84
github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
9-
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
10-
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
6+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
117
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
128
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
139
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
@@ -19,12 +15,10 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
1915
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
2016
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2117
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
22-
github.com/reeflective/readline v1.0.13 h1:TeJmYw9B7VRPZWfNExr9QHxL1m0iSicyqBSQIRn39Ss=
23-
github.com/reeflective/readline v1.0.13/go.mod h1:3iOe/qyb2jEy0KqLrNlb/CojBVqxga9ACqz/VU22H6A=
2418
github.com/reeflective/readline v1.0.15 h1:uB/M1sAc2yZGO14Ujgr/imLwQXqGdOhDDWAEHF+MBaE=
2519
github.com/reeflective/readline v1.0.15/go.mod h1:3iOe/qyb2jEy0KqLrNlb/CojBVqxga9ACqz/VU22H6A=
26-
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
27-
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
20+
github.com/reeflective/readline v1.1.1 h1:gplCdkwknFmly5BFBwVFJnMmQ/nWMrQvtkk7HizvGV0=
21+
github.com/reeflective/readline v1.1.1/go.mod h1:CwNkh9BmFBBCSO6mdDaNWb34rOqQsI9eYbxyqvOEazY=
2822
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
2923
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
3024
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 h1:3RPlVWzZ/PDqmVuf/FKHARG5EMid/tl7cv54Sw/QRVY=
@@ -34,24 +28,18 @@ github.com/rsteube/carapace v0.46.3-0.20231214181515-27e49f3c3b69/go.mod h1:4ZC5
3428
github.com/rsteube/carapace-shlex v0.1.1 h1:fRQEBBKyYKm4TXUabm4tzH904iFWSmXJl3UZhMfQNYU=
3529
github.com/rsteube/carapace-shlex v0.1.1/go.mod h1:zPw1dOFwvLPKStUy9g2BYKanI6bsQMATzDMYQQybo3o=
3630
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
37-
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
3831
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
3932
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
4033
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
41-
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
4234
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
43-
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4=
44-
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
45-
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI=
46-
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
47-
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
48-
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
49-
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
50-
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
51-
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
52-
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
53-
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
54-
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
35+
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
36+
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
37+
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac h1:l5+whBCLH3iH2ZNHYLbAe58bo7yrN4mVcnkHDYz5vvs=
38+
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac/go.mod h1:hH+7mtFmImwwcMvScyxUhjuVHR3HGaDPMn9rMSUUbxo=
39+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
40+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
41+
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
42+
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
5543
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
5644
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
5745
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

line.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func split(input string, hl bool) (words []string, remainder string, err error)
9191
}
9292

9393
input = input[l:]
94+
9495
continue
9596
} else if c == escapeChar {
9697
// Look ahead for escaped newline so we can skip over it
@@ -99,9 +100,12 @@ func split(input string, hl bool) (words []string, remainder string, err error)
99100
if hl {
100101
remainder = string(escapeChar)
101102
}
103+
102104
err = errUnterminatedEscape
103-
return
105+
106+
return words, remainder, err
104107
}
108+
105109
c2, l2 := utf8.DecodeRuneInString(next)
106110
if c2 == '\n' {
107111
if hl {
@@ -111,20 +115,25 @@ func split(input string, hl bool) (words []string, remainder string, err error)
111115
words[len(words)-1] += string(c) + string(c2)
112116
}
113117
}
118+
114119
input = next[l2:]
120+
115121
continue
116122
}
117123
}
118124

119125
var word string
126+
120127
word, input, err = splitWord(input, &buf, hl)
121128
if err != nil {
122129
remainder = input
123-
return
130+
return words, remainder, err
124131
}
132+
125133
words = append(words, word)
126134
}
127-
return
135+
136+
return words, remainder, err
128137
}
129138

130139
// splitWord has been modified to return the remainder of the input (the part that has not been
@@ -185,6 +194,7 @@ escape:
185194
}
186195
input = input[l:]
187196
}
197+
188198
goto raw
189199

190200
single:
@@ -270,11 +280,13 @@ func trimSpacesMatch(remain []string) (trimmed []string) {
270280

271281
func (c *Console) lineEmpty(line string) bool {
272282
empty := true
283+
273284
for _, r := range line {
274285
if !strings.ContainsRune(string(c.EmptyChars), r) {
275286
empty = false
276287
break
277288
}
278289
}
290+
279291
return empty
280292
}

menu.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (m *Menu) DeleteHistorySource(name string) {
131131
name = " (" + name + ")"
132132
}
133133

134-
name = fmt.Sprintf("local history%s", name)
134+
name = "local history" + name
135135
}
136136

137137
delete(m.histories, name)
@@ -169,7 +169,7 @@ func (m *Menu) TransientPrintf(msg string, args ...any) (n int, err error) {
169169
buf := m.out.String()
170170
m.out.Reset()
171171

172-
return m.console.TransientPrintf(buf)
172+
return m.console.TransientPrintf("%s", buf)
173173
}
174174

175175
// Printf prints a message to the console, but only if the current menu
@@ -196,7 +196,7 @@ func (m *Menu) Printf(msg string, args ...any) (n int, err error) {
196196
buf := m.out.String()
197197
m.out.Reset()
198198

199-
return m.console.Printf(buf)
199+
return m.console.Printf("%s", buf)
200200
}
201201

202202
// CheckIsAvailable checks if a target command is marked as filtered
@@ -330,7 +330,7 @@ func (m *Menu) defaultHistoryName() string {
330330
name = " (" + m.name + ")"
331331
}
332332

333-
return fmt.Sprintf("local history%s", name)
333+
return "local history" + name
334334
}
335335

336336
func (m *Menu) errorFilteredCommandTemplate(filters []string) string {
@@ -347,6 +347,7 @@ func tmpl(w io.Writer, text string, data interface{}) error {
347347
t := template.New("top")
348348
t.Funcs(templateFuncs)
349349
template.Must(t.Parse(text))
350+
350351
return t.Execute(w, data)
351352
}
352353

0 commit comments

Comments
 (0)