Skip to content
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

[Feature request] Support mode for env variables. #68

Closed
AllenDang opened this issue Sep 16, 2021 · 7 comments · Fixed by #86 or #264
Closed

[Feature request] Support mode for env variables. #68

AllenDang opened this issue Sep 16, 2021 · 7 comments · Fixed by #86 or #264
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@AllenDang
Copy link

Nice work! This is the restclient I'm looking for a long time.

Here is a common case when I test restful api in day to day work.

Define a env named {{base_url}} in both production and local modes. So I could switch to local to test the code in local server, and switch to prod after deployment.

The {{base_url}} may looks like this.

In production mode, base_url is http://xyz.abc/api/v1.0/something, and in local mode base_url is http://localhost:8080.

If rest.nvim could support this, I could replace my rest client for good.

@NTBBloodbath
Copy link
Member

Hey, thank you for kind words :)

This sounds like a really good feature, can you please tell me how do you switch modes? In that way I'll have a cleaner idea about how to implement this!

Regards

@NTBBloodbath NTBBloodbath added enhancement New feature or request good first issue Good for newcomers labels Sep 16, 2021
@AllenDang
Copy link
Author

AllenDang commented Sep 16, 2021

Here is a basic idea for your reference.

  1. Define env variables like this.
[Production] <- this is the mode name and the first mode will be the default mode.
base_url = ...

[Local]
base_url = ...
  1. Use base_url as usual in http file.

  2. Provide a set of api to:
    a. Get all the modes.
    b. Get current activated mode's name.
    c. Set current activated mode by name.

With those APIs I could integrate them easily with telescope (mode picker and switcher), feline (status line).

@NTBBloodbath
Copy link
Member

Thank you so much for such detailed explanation!

Never saw something like this before, do you know if this format is valid in NodeJS dotenv package? I want to know if this already exists so I can take a look at some implementations haha, it seems that we will need to change how our .env files reading process works

@NTBBloodbath
Copy link
Member

Alright so I'm implementing this on my own way atm, do you have any idea about how should we identify what environment mode should be used?

@jens1205
Copy link
Contributor

Perhaps you can draw some inspiration from https://www.jetbrains.com/help/idea/exploring-http-syntax.html#example-working-with-environment-files

@AllenDang
Copy link
Author

@NTBBloodbath Always use the first mode defined in env file as default is good enough for me.

@cagucor
Copy link

cagucor commented Nov 9, 2021

@NTBBloodbath what is the status of this feature?
I would love to have something like this, I'll learn lua if it helps to get it done faster 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants