Improve line-by-line processing to handle CRLF files #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request mainly modifies the
internal/cli/cli.go
file and the corresponding test files to improve the processing of text replacement and filtering. The changes include replacing thestring
type with[]byte
for the replacement variable and the input lines, modifying thereplaceProcess
andfilterProcess
methods to read input line by line without changing newline characters, and updating thematchesFilters
andcolorText
functions to work with[]byte
instead ofstring
.Changes in type and reading method:
internal/cli/cli.go
: Changed the type of thereplacement
variable fromstring
to[]byte
in theRun
method. [1] [2]internal/cli/cli.go
: Modified thereplaceProcess
andfilterProcess
methods to read input line by line when input is from a pipe without changing newline characters.Changes in functions:
internal/cli/cli.go
: Updated thematchesFilters
andcolorText
functions to work with[]byte
instead ofstring
.Test changes:
internal/cli/cli_test.go
: Updated the tests to reflect the changes in theRun
method and thereplaceProcess
function. [1] [2] [3] [4]internal/cli/export_test.go
: Updated the exportedReplaceProcess
function to reflect the changes in thereplaceProcess
function.internal/cli/testdata/test_crlf.txt
: Added a new test file to test the handling of CRLF text.