zacchiro / beangrep

Beangrep - grep-like filter for Beancount
GNU General Public License v2.0
11 stars 2 forks source link

Enable click's auto_envvar_prefix #20

Closed hoostus closed 3 months ago

hoostus commented 3 months ago

Enable click's auto_envvar_prefix which allows bean-grep's command line options to also be set via environment variables.

The prefix is BEANGREP so the environment variables are BEANGREP_VERBOSE, BEANGREP_CASE_SENSITIVE, etc.

This fixes #8

n.b. I just realised I haven't updated the documentation for this but if the PR is accepted I can do that.

The environment variables could either be set permanently & globally via your shell config file or you could use something direnv to set them just while inside your beancount directory.

I think the current defaults actually work fine and don't see a need for this. However, this is scaffolding for my next pull request which will let you also specify the beancount file via an environment.

hoostus commented 3 months ago

Hm, I'm clearly not very good at github since I ended up including both changes in this single PR. Let me know if you want me to rework anything......

zacchiro commented 3 months ago

Thanks a lot for this, which would indeed be a good (easy) way to address defaults. Please make the PR clean indeed, so that it only include one commit. (It is also fine if you don't want to use GitHub: just send me the output of git format-patch and I will be happy to apply it locally and push.)

More importantly though, I'd like to have at least a couple of tests for this, as it's something that can easily break unnoticed in the future. Can you give it a try? (I'm assuming click provides a way to set envvar via its CLI runner, but I never looked into it.)

hoostus commented 3 months ago

Give me a day or two to rework this (busy with family over the weekend so probably not until next week).