New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compare command #282
Add compare command #282
Conversation
0c993d1
to
aa881b7
Compare
89f7ff2
to
e407634
Compare
@mstruebing Thank you for your contribution! 🔥 I like this feature too ❤️ I think we will merge it after release v2.2.0. I have a few ideas how we can improve it, but I will come back with them a little later. |
I think it would also make sense to do this as a separate subcommand after #333 🤔 This can also be done as a separate PR later on. Just a suggestion) Multi-functional |
Yes, we are slowly moving towards this way 🙂 $ dotenv-linter check
$ dotenv-linter fix
$ dotenv-linter compare
$ dotenv-linter something_else If you have ideas what else we can include in the next release, let me know 😉 |
2d56d5b
to
d4d1400
Compare
I polished the PR a bit, feedback or desired changes are welcome |
I think this PR is on hold until the subcommands are finished, right? |
Yes, you are right 🙂 |
Subcommands are finished 🎉 |
98bcd9e
to
b923765
Compare
b923765
to
89075e2
Compare
I updated the PR right now as a subcommand |
Codecov Report
@@ Coverage Diff @@
## master #282 +/- ##
==========================================
+ Coverage 95.06% 95.19% +0.13%
==========================================
Files 34 36 +2
Lines 2310 2373 +63
==========================================
+ Hits 2196 2259 +63
Misses 114 114
Continue to review full report at Codecov.
|
@mstruebing Thank you! Can you explain how this feature should work? |
Sure, so in general what it does: I think this is handy for testing if different environments have some variables missing. Also sometimes you have an To try it out you can use the command in the first comment, just replace Do you have any further questions I did not answered? |
Right now the output of the $ dotenv-linter compare .env .env.local .env2
Comparing .env
Comparing .env.local
Comparing .env2
".env" is missing keys: "OK, MULTILINE"
".env.local" is missing keys: "OK, MULTILINE, 1MULTILINE, FOO, ZOO, WORLD"
".env2" is missing keys: "1MULTILINE, HELLO, ZOO, WORLD" I would like to see something like this: $ dotenv-linter compare .env .env.local .env2
Comparing .env
.env is missing keys: MULTILINE, OK
Comparing .env.local
.env.local is missing keys: FOO, 1MULTILINE, WORLD, MULTILINE, OK, ZOO
Comparing .env2
.env2 is missing keys: 1MULTILINE, HELLO, WORLD, ZOO What do you think? |
e5601f1
to
7664ce8
Compare
I think I adressed all of the review comments, still need to add some tests, however I have a problem now which I'm not able to fix:
for line in lines {
if let Some(key) = line.get_key() { // `line` does not live long enough: borrowed value does not live long enough
all_keys.insert(key);
keys.push(key)
}
} What can I do to prevent this, I tried multiple things without success? |
Take a look at my comments above. I have sketched the fastest solution of your problem, but not the most efficient 😅 |
24f5cc3
to
9f05c69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple of comments, please take a look 🙂
(this will also fix the current tests)
@dotenv-linter/core we should remember to add this to the documentation (dotenv-linter.github.io) |
9f05c69
to
4973de4
Compare
4973de4
to
0095068
Compare
Sorry for the long delay, I just pushed:
Is there anything else I need to do except documentation? |
I will add documentation for this command in dotenv-linter/dotenv-linter.github.io#16. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have done an amazing job! 🚀
Thank you! 👍
Co-authored-by: Grachev Mikhail <work@mgrachev.com>
@mstruebing Excellent work 🔥Thank you 👏 |
A proof of concept how comparing could work.
I think this isn't the cleanest implementation and needs some abstraction work in terms of types, and duplicate work between
compare
andrun
but I wanted to see if it can work and how it could work.We didn't already agreed that this feature needed to be added to the tool, but I liked the idea, found some time and had fun playing around with it.
So this could be the starting point of a discussion and further investigation of that topic.
What do you think?
Check this feature: