Here is the Main function for match:
func Main() int {
m, err := NewMatcher(
WithSearchTextFromArgs(os.Args[1:]),
)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
m.PrintMatchingLines()
return 0
}
Let's remove the ability to process arguments
func Main() int {
m, err := NewMatcher()
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
m.PrintMatchingLines()
return 0
}
Executing the tests will still pass.
Let's also modify matches_lines_from_stdin.txtar to add one additional line that should match
stdin three_matching_lines.txt
exec match MAGIC
stdout -count=1 '^this line is MAGIC\n'
stdout -count=1 '^MAGIC is also on this line\n'
stdout -count=1 '^and MAGIC is here too\n'
-- three_matching_lines.txt --
this won't match
this line is MAGIC
MAGIC is also on this line
but not this one
and MAGIC is here too
MAGIC is a lie
Tests still pass, even though we haven't added a stdout directive to match the new line.
Here is the
Mainfunction for match:Let's remove the ability to process arguments
Executing the tests will still pass.
Let's also modify
matches_lines_from_stdin.txtarto add one additional line that should matchTests still pass, even though we haven't added a
stdoutdirective to match the new line.