Skip to content

Commit a6b978d

Browse files
authored
Add -final-pass (#27)
1 parent 14abbeb commit a6b978d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/catp/catp/app.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ type runner struct {
5353
// skip is a slice of OR items, that are slices of AND items.
5454
skip [][][]byte
5555

56+
finalPass bool
57+
5658
currentFile *progress.CountingReader
5759
currentTotal int64
5860

@@ -272,6 +274,7 @@ func (r *runner) scanFile(filename string, rd io.Reader, out io.Writer) {
272274

273275
func (r *runner) shouldWrite(line []byte) bool {
274276
shouldWrite := false
277+
passed := false
275278

276279
if len(r.pass) == 0 {
277280
shouldWrite = true
@@ -289,6 +292,7 @@ func (r *runner) shouldWrite(line []byte) bool {
289292

290293
if orPassed {
291294
shouldWrite = true
295+
passed = true
292296

293297
break
294298
}
@@ -299,6 +303,10 @@ func (r *runner) shouldWrite(line []byte) bool {
299303
return shouldWrite
300304
}
301305

306+
if passed && r.finalPass {
307+
return true
308+
}
309+
302310
for _, orFilter := range r.skip {
303311
orPassed := true
304312

@@ -521,6 +529,7 @@ func Main(options ...func(o *Options)) error { //nolint:funlen,cyclop,gocognit,g
521529
cpuProfile := flag.String("dbg-cpu-prof", "", "write first 10 seconds of CPU profile to file")
522530
memProfile := flag.String("dbg-mem-prof", "", "write heap profile to file after 10 seconds")
523531
output := flag.String("output", "", "output to file (can have .gz or .zst ext for compression) instead of STDOUT")
532+
flag.BoolVar(&r.finalPass, "final-pass", false, "don't check skip if pass was successful")
524533
flag.BoolVar(&r.noProgress, "no-progress", false, "disable progress printing")
525534
flag.BoolVar(&r.countLines, "l", false, "count lines")
526535
flag.Float64Var(&r.rateLimit, "rate-limit", 0, "output rate limit lines per second")

0 commit comments

Comments
 (0)