Add extract feature to CLI for regex-based text extraction and printing #80
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 introduces a new
-extract
feature to the CLI tool, allowing users to extract and print text matching a given regex pattern. The most important changes include modifications to the CLI struct, the addition of the extract logic, and updates to the validation and testing processes.New Feature: Extract Option
internal/cli/cli.go
: AddedextractExpr
to theCLI
struct and implemented the logic to handle the-extract
option, including regex compilation, file processing, and standard input processing. [1] [2] [3]Validation Enhancements
internal/cli/cli.go
: Added new methodsvalidateMutuallyExclusiveOptions
andvalidateExpressionFormats
to ensure that incompatible options are not used together and that expression formats are valid.Testing Updates
internal/cli/cli_test.go
: Added test cases to cover various scenarios for the-extract
option, including basic extraction, multiple capture groups, and file processing.internal/cli/testdata/test_extract.txt
andinternal/cli/testdata/test_extract2.txt
: Added test data files to support the new test cases. [1] [2]