acheronfail / repgrep

An interactive replacer for ripgrep that makes it easy to find and replace across files on the command line.
Apache License 2.0
267 stars 4 forks source link

support reading RIPGREP_CONFIG_FILE #99

Closed acheronfail closed 10 months ago

acheronfail commented 11 months ago

Fixes #98

To Do:

acheronfail commented 11 months ago

Getting this right and in a maintainable way is actually rather difficult with what we have. Basically, the requirement is that rgr needs to do some parsing to get the information it needs, but also allow passing other options to rg.

These are the flags that rgr needs to know:

These are the flags that are unsupported by rgr:

Then, rgr itself will spawn rg with the --json flag, since we parse its JSON output to power its UI. The --json flag itself disallows some of rg's other options, but rg itself handles that so we don't have to. We can also disable the binary-related flags when spawning too, to override any if they were set.

Thus, the requirements for our argument parsing are to "sniff" our cmdline for the flags we need to know, bail out if we see a flag we don't support, and pass everything else through. We must also take into consideration the --config flag, since if it or RIPGREP_CONFIG_FILE is set, then we also need to sniff through the config file for any of the options we need.

I'm leaning towards re-writing rgr's argument parsing logic, since clap isn't exactly the right tool for this kind of thing, and it's only really being used as a whitelist anyway.

acheronfail commented 10 months ago

A fair amount of changes, especially some to CI, but they've been tested and things are looking good.

I'm going to create a release with the changes so far and see how it goes.