Skip to content

Commit

Permalink
Fix jumping line stats when multiple files are processed
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Jul 13, 2023
1 parent 2f5bd09 commit ba037d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cmd/catp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type runner struct {
pr *progress.Progress
sizes map[string]int64
readBytes int64
readLines int64
matches int64
totalBytes int64

Expand Down Expand Up @@ -124,7 +125,9 @@ func (r *runner) cat(filename string) (err error) {
t.CurrentBytes = func() int64 {
return r.readBytes + r.currentFile.Bytes()
}
t.CurrentLines = r.currentFile.Lines
t.CurrentLines = func() int64 {
return r.readLines + r.currentFile.Lines()
}
t.Task = filename
t.Continue = true
})
Expand All @@ -137,6 +140,7 @@ func (r *runner) cat(filename string) (err error) {

r.pr.Stop()
r.readBytes += r.currentFile.Bytes()
r.readLines += r.currentFile.Lines()

return r.lastErr
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bool64/progress
go 1.20

require (
github.com/bool64/dev v0.2.28
github.com/klauspost/compress v1.16.5
github.com/bool64/dev v0.2.29
github.com/klauspost/compress v1.16.7
github.com/klauspost/pgzip v1.2.6
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github.com/bool64/dev v0.2.28 h1:6ayDfrB/jnNr2iQAZHI+uT3Qi6rErSbJYQs1y8rSrwM=
github.com/bool64/dev v0.2.28/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/bool64/dev v0.2.29 h1:x+syGyh+0eWtOzQ1ItvLzOGIWyNWnyjXpHIcpF2HvL4=
github.com/bool64/dev v0.2.29/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=

0 comments on commit ba037d2

Please sign in to comment.