tomnomnom/gf

Backends other than grep

Jab2870 opened this issue · 2 comments

I am thinking that I might create a pull request that would allow use of backends such as ripgrep as a backend rather than grep.

Is this something you would be interested in?

Obviously, some of the flags are different when using a different tool. I propose changing the json files from this:

{
	"flags": "-oriahE",
	"pattern": "https?://[^\"\\'> ]+"
}

to something more like this:

{	"rg": {
		"flags": "-olIN --binary",
		"pattern": "https?://[^'\"]+"
	},
	"grep": {
		"flags": "-oriahE",
		"pattern": "https?://[^\"\\'> ]+"
	}
}

Note, I haven't tested the rg command above but it should give you an idea of how it could work.

For each json file, it would do the first that it could. The key for each section would be the command to run. In this case, it would try to use rg, if that wasn't available it would try grep.

This way, if someone wanted to use silver surfer or something else, they could.

I am not sure when I will get around to implementing this although it probably won't be for a couple of weeks.

Do you have any requests or suggestions? I am mostly looking for feedback on the proposed json format change.

I would also suggest adding a command line flag that would force it to use a particular command

Hi @Jab2870!

I think this is a good idea. I'll give it some thought over the next week or two of how best to move forward in a way that maintains backwards compatibility without making the code too cumbersome.

Thanks!