DopplerHQ / cli

The official CLI for interacting with your Doppler secrets and configuration.
https://docs.doppler.com
Apache License 2.0
218 stars 44 forks source link

[FEATURE] Automatically source env on terminal open in VSCode #285

Open clouedoc opened 2 years ago

clouedoc commented 2 years ago

Is your feature request related to a problem? Please describe.

I wouldn't say that I like typing "doppler run " each time I use my CLI.

Describe the solution you'd like

I would like to have a doppler source command to source environment variables to the local terminal. I would also like to have a VSCode or ZSH integration that would do that for me.

Describe alternatives you've considered

I wrote this command to download and source secrets to the local terminal:

eval $(doppler secrets download --format env --no-file --fallback-only)

I am still wondering how to run a command on each ZSH terminal open.

Final solution for me

I've created an alias that I run each time I want to seed environment variables to the current terminal:

alias denv="eval \$(doppler secrets download --format env --no-file --fallback-only)"

Then, I can call it like this:

denv

Additional context

My IDE is VSCode.

YarikRevich commented 2 years ago

The only solution fixes your issue is to make command "dopler source" return "eval $(doppler secrets download --format env --no-file --fallback-only)" command, which you should then write anyone to the terminal on you own again... because there is no such opportunity to apply env vars to your terminal just calling "dopler env" once.

ryan-blunden commented 2 years ago

@clouedoc Would creating a VS Code launch configuration that uses the Doppler CLI to run your application be another option?

Could you expand upon why you need the secrets exposed in your shell instead of to specific commands or scripts?

clouedoc commented 2 years ago

@ryan-blunden creating a VS Code launch configuration wouldn't be enough since some commands require dynamic input, and it would be a burden to create Launch Configurations each time.

e.g. testing a subportion of the app

Piccirello commented 1 year ago

We now have a vscode extension that you can use. Alternatively, I would suggest starting a new shell with your secrets injected, rather than injecting them into the existing shell. You can do so using doppler run -- bash (replace bash with your preferred shell).

clouedoc commented 1 year ago

That's great news! It's making me want to give Doppler another try 😃 . I'll close this issue since it should be "fixed" by the VSCode extension.