Skip to content

Commit d7c684d

Browse files
authored
refactor: rename LineNumberer to NumberLines and update aliases (#66)
* refactor: rename LineNumberer to NumberLines and update aliases * fix: update aliases for number-lines command
1 parent a109f08 commit d7c684d

File tree

6 files changed

+36
-40
lines changed

6 files changed

+36
-40
lines changed

cmd/processor_number-lines.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ go 1.24.5
55
require (
66
github.com/cespare/xxhash/v2 v2.3.0
77
github.com/charmbracelet/bubbles v0.21.0
8-
github.com/charmbracelet/bubbletea v1.3.6
8+
github.com/charmbracelet/bubbletea v1.3.9
99
github.com/charmbracelet/lipgloss v1.1.0
1010
github.com/ghodss/yaml v1.0.0
1111
github.com/iancoleman/strcase v0.3.0
12-
github.com/lucasb-eyer/go-colorful v1.2.0
12+
github.com/lucasb-eyer/go-colorful v1.3.0
1313
github.com/mcnijman/go-emailaddress v1.1.1
1414
github.com/spf13/cobra v1.9.1
1515
github.com/vmihailenco/msgpack/v5 v5.4.1
1616
github.com/yuin/goldmark v1.7.13
1717
gitlab.com/abhimanyusharma003/go-ordered-json v0.0.0-20200508150302-7ef32eef8ead
18-
golang.org/x/crypto v0.41.0
19-
golang.org/x/term v0.34.0
18+
golang.org/x/crypto v0.42.0
19+
golang.org/x/term v0.35.0
2020
mvdan.cc/xurls/v2 v2.6.0
2121
)
2222

@@ -47,9 +47,8 @@ require (
4747
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
4848
github.com/zeebo/xxh3 v1.0.2 // indirect
4949
golang.org/x/net v0.43.0 // indirect
50-
golang.org/x/sync v0.16.0 // indirect
51-
golang.org/x/sys v0.35.0 // indirect
52-
golang.org/x/text v0.28.0 // indirect
50+
golang.org/x/sys v0.36.0 // indirect
51+
golang.org/x/text v0.29.0 // indirect
5352
gopkg.in/yaml.v2 v2.4.0 // indirect
5453
gopkg.in/yaml.v3 v3.0.1 // indirect
5554
)

go.sum

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
88
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
99
github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
1010
github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
11-
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
12-
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
11+
github.com/charmbracelet/bubbletea v1.3.9 h1:OBYdfRo6QnlIcXNmcoI2n1NNS65Nk6kI2L2FO1puS/4=
12+
github.com/charmbracelet/bubbletea v1.3.9/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
1313
github.com/charmbracelet/colorprofile v0.3.2 h1:9J27WdztfJQVAQKX2WOlSSRB+5gaKqqITmrvb1uTIiI=
1414
github.com/charmbracelet/colorprofile v0.3.2/go.mod h1:mTD5XzNeWHj8oqHb+S1bssQb7vIHbepiebQ2kPKVKbI=
1515
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
@@ -41,8 +41,8 @@ github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBF
4141
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
4242
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
4343
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
44-
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
45-
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
44+
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
45+
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
4646
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
4747
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
4848
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
@@ -85,23 +85,21 @@ github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
8585
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
8686
gitlab.com/abhimanyusharma003/go-ordered-json v0.0.0-20200508150302-7ef32eef8ead h1:JzI8XDh2gVmJqe5n+F2MHhxGpL9efc4ZgBjXpY6fDrs=
8787
gitlab.com/abhimanyusharma003/go-ordered-json v0.0.0-20200508150302-7ef32eef8ead/go.mod h1:rzwdkxQuwcyF+elCTRk7kbXOI7Bj/UkmDDIhjPOrvdw=
88-
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
89-
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
88+
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
89+
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
9090
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
9191
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
9292
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
9393
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
9494
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
95-
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
96-
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
9795
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9896
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
99-
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
100-
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
101-
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
102-
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
103-
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
104-
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
97+
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
98+
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
99+
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
100+
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
101+
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
102+
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
105103
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
106104
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
107105
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

processors/numberlines.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import (
66
"strings"
77
)
88

9-
// / Prepends consecutive number to each line of input
10-
type LineNumberer struct{}
9+
// NumberLines Prepends consecutive number to each line of input
10+
type NumberLines struct{}
1111

12-
func (p LineNumberer) Name() string {
12+
func (p NumberLines) Name() string {
1313
return "number-lines"
1414
}
1515

16-
func (p LineNumberer) Alias() []string {
17-
return []string{"nl"}
16+
func (p NumberLines) Alias() []string {
17+
return []string{"nl", "line-numbers", "line-number", "number-line", "numberlines", "numberline"}
1818
}
1919

2020
func nonEmptyCount(strs []string) int {
@@ -26,7 +26,7 @@ func nonEmptyCount(strs []string) int {
2626
}
2727
return count
2828
}
29-
func (p LineNumberer) Transform(data []byte, _ ...Flag) (string, error) {
29+
func (p NumberLines) Transform(data []byte, _ ...Flag) (string, error) {
3030
var s = string(data)
3131
var counter = 1
3232
var result = ""
@@ -39,24 +39,23 @@ func (p LineNumberer) Transform(data []byte, _ ...Flag) (string, error) {
3939
counter++
4040
}
4141
result += line + "\n"
42-
4342
}
4443
result = strings.TrimSuffix(result, "\n")
4544
return result, nil
4645
}
4746

48-
func (p LineNumberer) Flags() []Flag {
47+
func (p NumberLines) Flags() []Flag {
4948
return nil
5049
}
5150

52-
func (p LineNumberer) Title() string {
51+
func (p NumberLines) Title() string {
5352
return "Line numberer"
5453
}
5554

56-
func (p LineNumberer) Description() string {
55+
func (p NumberLines) Description() string {
5756
return "Prepends consecutive number to each input line"
5857
}
5958

60-
func (p LineNumberer) FilterValue() string {
59+
func (p NumberLines) FilterValue() string {
6160
return p.Title()
6261
}

processors/numberlines_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66
)
77

8-
func TestLineNumberer_Command(t *testing.T) {
8+
func TestNumberLines_Command(t *testing.T) {
99
test := struct {
1010
alias []string
1111
description string
@@ -14,14 +14,14 @@ func TestLineNumberer_Command(t *testing.T) {
1414
name string
1515
title string
1616
}{
17-
alias: []string{"nl"},
17+
alias: []string{"nl", "line-numbers", "line-number", "number-line", "numberlines", "numberline"},
1818
description: "Prepends consecutive number to each input line",
1919
filterValue: "Line numberer",
2020
flags: nil,
2121
name: "number-lines",
2222
title: "Line numberer",
2323
}
24-
p := LineNumberer{}
24+
p := NumberLines{}
2525
if got := p.Alias(); !reflect.DeepEqual(got, test.alias) {
2626
t.Errorf("Alias() = %v, want %v", got, test.alias)
2727
}
@@ -42,7 +42,7 @@ func TestLineNumberer_Command(t *testing.T) {
4242
}
4343
}
4444

45-
func TestLineNumberer_Transform(t *testing.T) {
45+
func TestNumberLines_Transform(t *testing.T) {
4646
type args struct {
4747
data []byte
4848
in1 []Flag
@@ -101,7 +101,7 @@ func TestLineNumberer_Transform(t *testing.T) {
101101
}
102102
for _, tt := range tests {
103103
t.Run(tt.name, func(t *testing.T) {
104-
p := LineNumberer{}
104+
p := NumberLines{}
105105
got, err := p.Transform(tt.args.data, tt.args.in1...)
106106
if (err != nil) != tt.wantErr {
107107
t.Errorf("Transform() error = %v, wantErr %v", err, tt.wantErr)

processors/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var List = []list.Item{
4343
MorseCodeDecode{},
4444
MD5{},
4545
MSGPACKToJSON{},
46-
LineNumberer{},
46+
NumberLines{},
4747
Pascal{},
4848
RemoveNewLines{},
4949
RemoveSpaces{},

0 commit comments

Comments
 (0)