You are not logged in.

https://github.com/supertanker/ruplacer/
Ruplacer is a command-line tool to find and replace text in source files.
Features:
Honor .gitignore
Ignore binary files
Fast
Can replace patterned captured as a grouped regex
Dry run by default, use --go to write changes to disk
--subvert mode to perform case conversion
Subvert mode takes care of snake_case versus CamelCase:
$ ruplacer --subvert foo_bar spam_eggs
Patching src/foo.txt
-- foo_bar, FooBar, and FOO_BAR!
++ spam_eggs, SpamEggs, and SPAM_EGGS!Ruplacer is available in the AUR.
If you find it useful, have some questions, or any kind of feedback, please let me know ![]()
P.S: You can also find details of how ruplacer works and a little bit about its history on my blog
Last edited by dmerej (2018-10-16 16:16:35)
Responsible Coder, Python Fan, Rust enthusiast
Offline
How is this different from just using sed? E.g.,
# Preview:
sed -n '/old/{s/^/-- /p;s/^--/++/;s/old/new/gp;}' *
# Do it:
sed -i 's/old/new/g' *Last edited by Trilby (2018-10-16 14:33:37)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I knew you would ask ![]()
Well, there's the nice color output, the syntax is easier to remember and it's fast and cross-platform. But yeah, UNIX tools work great for this kind of task.
I just think that sometimes we can take time to rewrite some of these tools and come up with more ergonomic alternatives ![]()
Responsible Coder, Python Fan, Rust enthusiast
Offline
You already listed a few differences in your initial post.
* parse .gitignore
* --subvert
Then in your readme you mention it ignores binary files.
It can also follow large directory trees that don't fit in a single command line, but that is really unlikely. My shell allows more than 2 million characters.
This could all be done with find, sed and filter scripts called with -exec, but in the end you just have a shell script instead of a rust binary.
Last edited by progandy (2018-10-16 15:17:07)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |
Offline
Thanks progandy, I've updated the introduction a little
Responsible Coder, Python Fan, Rust enthusiast
Offline