Skip to content

Commit

Permalink
feat: refactor packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dcilke committed Apr 27, 2023
1 parent 72ee711 commit 8a8caea
Show file tree
Hide file tree
Showing 40 changed files with 58 additions and 569 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ install: build
test: build-test
@rm -rf .covdata
@mkdir .covdata
@go test -v ./... -timeout=30s -coverprofile=.covdata/coverage.out -covermode=atomic
@go test -race ./... -timeout=30s -coverprofile=.covdata/coverage.out -covermode=atomic
@go tool cover -html=.covdata/coverage.out -o .covdata/coverage.html
@go tool cover -func=.covdata/coverage.out
18 changes: 10 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ module github.com/dcilke/hz
go 1.18

require (
github.com/dcilke/goj v0.0.4
github.com/dcilke/golden v0.1.0
github.com/jessevdk/go-flags v1.5.0
github.com/mattn/go-colorable v0.1.12
github.com/sanity-io/litter v1.5.5
github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312
github.com/stretchr/testify v1.8.2
)

require (
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b // indirect
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dcilke/goj v0.0.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sanity-io/litter v1.5.5 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
github.com/kylelemons/godebug v1.1.0
github.com/dcilke/gu v0.1.0
github.com/dcilke/heron v0.1.0
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
)

// replace github.com/dcilke/gojay v1.2.16 => ../gojay
26 changes: 23 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b h1:XxMZvQZtTXpWMNWK82vdjCLCe7uGMFXdTsJH0v3Hkvw=
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dcilke/goj v0.0.4 h1:6eALC7dYxCeivCA70KgLzgvtvC5o5UDPXz1LGdPtonM=
github.com/dcilke/goj v0.0.4/go.mod h1:O4aVQNzLPaosmERdEfePM6qMzl2mnnNr/tb8MP8oMno=
github.com/dcilke/golden v0.1.0 h1:5TRihP8pdy/h5I++ypFGKXT6CrI1y1Jn+2Nw/7qc9Ko=
github.com/dcilke/golden v0.1.0/go.mod h1:KxQFVmzRGf7A9jPbCMXIDr9kQxwnZZ7i07wWyihuhNU=
github.com/dcilke/gu v0.1.0 h1:oxkaeVJ+AzC992otWFqt2gku4U/VyzO62ZscWOUbQ9M=
github.com/dcilke/gu v0.1.0/go.mod h1:8lZQPS+FeUGA7Lc3YAaG+cEYA0VAUYBKBGACsCkpgzI=
github.com/dcilke/heron v0.1.0 h1:/t9SOiESJbBrpxkkRhcOQTEdqRtW/vcGW9w6K66lxcc=
github.com/dcilke/heron v0.1.0/go.mod h1:f9h5pFjBLvwc8tJfrbejvI9yOm3KEx2f6HOXLf/NWRw=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
Expand All @@ -10,13 +18,25 @@ github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZb
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 h1:GD+A8+e+wFkqje55/2fOVnZPkoDIu1VooBWfNrnY8Uo=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo=
github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U=
github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312 h1:UsFdQ3ZmlzS0BqZYGxvYaXvFGUbCmPGy8DM7qWJJiIQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion integration/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package integration
import (
"testing"

"github.com/dcilke/hz/pkg/golden"
"github.com/dcilke/golden"
"github.com/stretchr/testify/require"
)

Expand Down
24 changes: 12 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"os"

"github.com/dcilke/hz/pkg/emitter"
"github.com/dcilke/hz/pkg/terminator"
"github.com/dcilke/gu"
"github.com/dcilke/heron"
"github.com/dcilke/hz/pkg/writer"
"github.com/jessevdk/go-flags"
)
Expand All @@ -28,35 +28,35 @@ func main() {
fmt.Fprint(os.Stderr, fmt.Errorf("unable to parse arguments: %w", err))
}

bufSize := emitter.DefaultBufSize
bufSize := heron.DefaultBufSize
if cmd.Strict {
bufSize = 0
}

w := writer.New(
writer.WithLevelFilters(cmd.Level),
)
e := emitter.New(
emitter.WithBufSize(bufSize),
emitter.WithJSON(func(a any) {
h := heron.New(
heron.WithBufSize(bufSize),
heron.WithJSON(func(a any) {
s, _ := w.WriteAny(a)
if s > 0 {
w.Println()
}
}),
emitter.WithBytes(func(b []byte) {
heron.WithBytes(func(b []byte) {
s, _ := w.Print(string(b))
if s > 0 {
w.Println()
}
}),
emitter.WithError(func(err error) {
heron.WithError(func(err error) {
fmt.Fprint(os.Stderr, fmt.Errorf("extractor error: %w", err))
}),
)

terminator.OnSig(func() int {
e.Flush()
gu.Terminator(func() int {
h.Flush()
return 0
})

Expand All @@ -66,10 +66,10 @@ func main() {
if err != nil {
fmt.Fprint(os.Stderr, fmt.Errorf("unable to open %q: %w", filename, err))
}
e.Process(f)
h.Process(f)
}
return
}

e.Process(os.Stdin)
h.Process(os.Stdin)
}
138 changes: 0 additions & 138 deletions pkg/emitter/emitter.go

This file was deleted.

Loading

0 comments on commit 8a8caea

Please sign in to comment.