support multi-line regex replacements #52
Merged
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 primarily focuses on enhancing the
replaceProcess
function in theinternal/cli/cli.go
file and updating the corresponding test cases ininternal/cli/cli_test.go
. The changes allow thereplaceProcess
function to handle both terminal and file inputs differently, thereby improving its overall functionality. Additionally, a new test fileinternal/cli/testdata/testsql.txt
has been added to aid in the testing process.Here are the key changes, grouped by theme:
Improvements to
replaceProcess
function:internal/cli/cli.go
: ThereplaceProcess
function now checks whether the input is from a terminal or a file. If it's from a terminal, it reads all data at once, performs the regex replacement, and writes the modified data to the output stream. If it's from a file, it processes the input line by line. This enhancement improves the function's ability to handle different types of inputs. [1] [2]Updates to test cases:
internal/cli/cli_test.go
: New test cases have been added to bothTestRun_successProcess
andTestRun_successProcessOnTerminal
functions. These test cases provide multiple lines for replacement, thereby ensuring thereplaceProcess
function correctly handles such scenarios. [1] [2]Addition of new test file:
internal/cli/testdata/testsql.txt
: This new test file contains SQL commands for creating tables. It is used in the new test cases to test thereplaceProcess
function's ability to handle multiple lines for replacement.