Skip to content
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

Add fail mode to exit with non-zero status if no matches found #65

Merged
merged 2 commits into from
Aug 11, 2024

Conversation

catatsuy
Copy link
Owner

This pull request introduces a new failMode feature to the CLI tool, which ensures the program exits with a specific status code if no matches are found during a replace operation. It also adjusts the exit codes for various error scenarios.

Key changes include:

New Feature: failMode

  • Added failMode boolean flag to the CLI struct and its associated command-line flag. (internal/cli/cli.go) [1] [2]
  • Updated the replaceProcess method to return a boolean indicating whether any matches were found. (internal/cli/cli.go) [1] [2]
  • Modified the Run method to check the failMode flag and exit with a new ExitCodeNoMatch if no matches are found. (internal/cli/cli.go) [1] [2]

Exit Code Adjustments

  • Changed the exit codes for ExitCodeParseFlagError and ExitCodeFail to 2, and introduced ExitCodeNoMatch with a value of 1. (internal/cli/cli.go)

Test Updates

  • Updated existing tests and added new tests to cover the failMode feature and adjusted exit codes. (internal/cli/cli_test.go) [1] [2] [3] [4] [5] [6] [7] [8]
  • Modified the ReplaceProcess method in the test export file to match the new signature. (internal/cli/export_test.go)

@catatsuy catatsuy force-pushed the feature-add-fail-mode branch from 1eac663 to a849308 Compare August 11, 2024 07:25
@catatsuy catatsuy changed the title Update exit codes and add fail mode for no matches in CLI operations Add fail mode to exit with non-zero status if no matches found Aug 11, 2024
@catatsuy catatsuy merged commit 7534988 into main Aug 11, 2024
5 checks passed
@catatsuy catatsuy deleted the feature-add-fail-mode branch August 11, 2024 23:32
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