Skip to content

Add extract feature to CLI for regex-based text extraction and printing #80

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
Nov 17, 2024

Conversation

catatsuy
Copy link
Owner

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: Added extractExpr to the CLI 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 methods validateMutuallyExclusiveOptions and validateExpressionFormats 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 and internal/cli/testdata/test_extract2.txt: Added test data files to support the new test cases. [1] [2]

@catatsuy catatsuy force-pushed the feature-extract-expression-support branch from af14793 to 9c4989d Compare November 17, 2024 07:42
@catatsuy catatsuy merged commit 0c8f1d0 into main Nov 17, 2024
5 checks passed
@catatsuy catatsuy deleted the feature-extract-expression-support branch November 17, 2024 07:50
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