$ show your-tools/ruplacer
Ruplacer is a command-line tool written in Rust for finding and replacing text in files. It supports literal string, regex, and case-preserving replacements, and provides a diff-like output of changes. The tool respects .gitignore, allows filtering by file type, and can operate in a dry-run mode. The architecture is modular, with separate modules for argument parsing, console output, directory traversal, file processing, and the core replacement logic. The replacement logic is particularly notable for its use of the strategy pattern to handle different matching algorithms in a uniform way.
The LLM identified 2 files worth highlighting for reuse:
Implements core find-and-replace functionality using the strategy pattern to handle literal strings, regex, and case-preserving replacements. Self-contained with minimal dependencies (regex and Inflector), making it highly reusable in any text processing project. Demonstrates non-obvious skill in unifying different matching algorithms through a common fragment-based approach.
Provides flexible console output with verbosity control and color support. The print_replacement method generates unified diff-like output for string replacements, which is reusable in any CLI tool needing to show changes. Self-contained with only the colored crate as a dependency, demonstrating clean separation of concerns.