Skip to content

support multi-line regex replacements #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2024

Conversation

catatsuy
Copy link
Owner

This pull request primarily focuses on enhancing the replaceProcess function in the internal/cli/cli.go file and updating the corresponding test cases in internal/cli/cli_test.go. The changes allow the replaceProcess function to handle both terminal and file inputs differently, thereby improving its overall functionality. Additionally, a new test file internal/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: The replaceProcess 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 both TestRun_successProcess and TestRun_successProcessOnTerminal functions. These test cases provide multiple lines for replacement, thereby ensuring the replaceProcess 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 the replaceProcess function's ability to handle multiple lines for replacement.

@catatsuy catatsuy merged commit 2b550da into main May 18, 2024
@catatsuy catatsuy deleted the feature_support_multiple_regexp_for_replacement branch May 18, 2024 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant