Skip to content

Conversation

@afh
Copy link
Contributor

@afh afh commented Feb 21, 2024

to export only given environment variables.

What are your thoughts on this, @humblepenguinn?
Do you think this is a useful addition or does it make envio interface too complicated?

I think this can be quite useful. Personally I'm not using profiles as much, but want to be able to export only certain variables to and .env file for testing.

Not sure if my approach is very rusty or elegant, looking forward to your feedback 🙂

@afh afh requested a review from humblepenguinn as a code owner February 21, 2024 22:10
to export only given environment variables
Alongside passing environment variables through the command line, if the user leaves the `--envs` key empty, `envio` will then provide the user with a multi-select prompt for them to select the environment variables they wish to export.
There was a bug in the filtering condition. Instead of `.filter(|item| !envs.contains(item))` it has to be `.filter(|item| envs.contains(item))`
@humblepenguinn
Copy link
Owner

This is a great idea @afh. There wasn't any issue with the code except a very small bug in the filtering condition in the export_envs function.

Alongside your current implementation, I also added a feature where if the user leaves the --envs argument empty, envio providers a multi select prompt where they can select the environment variables they wish to export.

Also I haven't used the nix pacakge manager before so I do not know what a flake is, so could you explain what that file actually is.

Thank you for the pull request! Appreciate it

@afh
Copy link
Contributor Author

afh commented Feb 23, 2024

Glad to hear that you like the idea, @humblepenguinn. Thank you for addressing the issues and improving this PR, much appreciated!

I like what you have done, so that users are able to select the variables to export. Here are two more things that I think could improve the change:

  1. Only provide the selection method when --envs was passed but no arguments it. This allows users to use envio export default to export the whole environment if they wish and envio export default --envs to select.

  2. As a vi user I'd prefer to be able to use the vi cursor keys and/or CTRL-n and CTRL-p.

From my understanding and use a flake is a file that describes in a stand-alone manner all the dependencies and commands necessary to build a certain software. A flake can have multiple outputs (think installable program, documentation, and accompanying static website). And flakes pin the versions for the source and its dependencies, so that it becomes universally reproducible.

Hope this helps and my understanding isn't too far from the reality ;)

@humblepenguinn
Copy link
Owner

Thank you for your suggestions, @afh they sound pretty good. I am a bit unsure about the VI key bindings, though. That would be a feature that Vim/Neovim users would appreciate but might not appeal to everyone. Perhaps we could add another flag or create a configuration file that envio loads.

If we decide to create a config file, then having just one singular key won't look good. We would need to implement configuration for a lot more stuff. Do you have any ideas as to what we can add? I've been thinking about implementing this for some time, so this sounds like a good excuse to do so.

The concept of a flake sounds pretty cool. I took a look at the nix package manager, and it sounds amazing. I might shift to it, however, it has a steep learning curve, according to my research.

Do you think a flake file is something that would help other people wanting to contribute to the project? Or is it something for nix users only? Also, is the flake file cross-platform? I saw "darwin" written, so I think it's macOS only right?. Or am I wrong? 😅

@humblepenguinn humblepenguinn merged commit 95878ee into humblepenguinn:main Feb 26, 2024
@afh afh deleted the export-envs branch February 26, 2024 08:32
@afh
Copy link
Contributor Author

afh commented Feb 26, 2024

Thanks for merging this already, @humblepenguinn, much appreciated!

Is it possible to have multiple key bindings at the same time, so that the cursor keys and vi-keys and CTRL-n and CTRL-p all work, regardless of user preference?

Personally I'd like to avoid config files for as long as possible and currently to not see the need for this project. That said I've only scratched the surface of envio. What other uses than keybindings to you see for an envio config file?

I highly recommend nixpkgs! And learning it can be quite the struggle. Happy to help or answer question as these always provide a good opportunity to learn.

I don't think adding a flake.nix would motivate people to contribute to the project directly, yet it would help folks already using nix to run envio. Bear in mind though that envio is already available as a package in nix and thus can easily be installed and run.

Yes, a flake is something that requires nix.
Yes, a flake is indeed cross-platform and not specific to macOS.

I'm looking into adding a flake.nix to this project, but am running into issues with pkg-config not being found. In case I make notable progress I'll create a PR.

Hope this helps :)

@afh
Copy link
Contributor Author

afh commented Feb 26, 2024

Apologies for having accidentally added the flake.{nix,lock} files, and thanks for removing them from this PR! 👍

@humblepenguinn
Copy link
Owner

Thank you for the contribution @afh! Currently envio uses the inquire crate for its interactive prompts. So I will have to check the documentation to see if multiple key bindings are available or even if modifying the key bindings is a option.

I agree, a configuration file for envio seems a bit early. There are a few places where we could add some sort of configuration but I don't think it would be something user's would be interested in. So that is something we can take a look at some other time.

Adding a flake.nix file seems like a great idea, be sure to open a pull request when you get it to work. I am currently learning about the nix pacakge manager and hopefully am able to use all of its wonderful features! I'll be sure to reach out to you whenever I need some help :D.

@humblepenguinn
Copy link
Owner

Apologies for having accidentally added the flake.{nix,lock} files, and thanks for removing them from this PR! 👍

It was something I wanted to add but after taking a look at the file my gut feeling was that it wasn't cross platform, so I decided to omit it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants