Shopify / shadowenv

reversible directory-local environment variable manipulations
https://shopify.github.io/shadowenv/
MIT License
396 stars 18 forks source link

Add `--json` to diff, for use from scripts / tooling #110

Open necaris opened 1 year ago

necaris commented 1 year ago

For some tooling (e.g. editors, prompts) it's helpful to know what modifications Shadowenv has made, in a short summary. This PR adds a changes subcommand that does just that: prints out a summary of the form +added -removed ^updated.

Example of this working with a Starship prompt:

Screenshot 2022-12-23 at 13 47 44
lugray commented 1 year ago

This seems like a fairly niche use case with incredibly specific output. I'm not sure that it warrants an entire subcommand. It does seem like there's a use case to serve here though. It's quite similar in concept to shadowenv diff. I think that if you were to implement a shadowenv diff --json, a script could process that output to do whatever it wished with it, making it much more generally useful. And a script could process it relatively easily to produce an output like you desire.

lugray commented 1 year ago

Thanks for taking on the feedback. I think this is going to be a nice feature. I'll be happy to re-review once you mark it ready, or answer any questions you may have in the meantime.