3 ms·
astgrep is a very useful tool when grep fails: https://ast-grep.github.io/ https://ast-grep.github.io/ It's not as easy to use as grep but I think one can scri
by t43562 2y ago
astgrep is a very useful tool when grep fails: https://ast-grep.github.io/ https://ast-grep.github.io/
It's not as easy to use as grep but I think one can script it to be nearly so. It has huge power but without learning it all one can do searches that grep finds difficult. e.g. finding all the locations where a method is called and showing the parameters even if they are on multiple lines. You can then use rewrite rules to do CLI code refactoring.
I think it also has potential in a build toolchain e.g. to look for patterns you want to discourage as a pre-commit hook.
ultragrep - https://github.com/zendesk/ultragrep https://github.com/zendesk/ultragrep - I don't love this quite as much but it does have a way to build indexes so you can do fast greps across a big codebase. It also has a text mode UI if you want it and I find that almost worthwhile.
I use ripgrep most of the time but while I like it, there is a limit to how many grep tools I can remember and I should probably cut down to using ultragrep and astgrep.
plain gnu grep itself is something one has to know when one is on an unfamiliar machine.