DopplerHQ / cli

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

[FEATURE] Dedicated command for the CLI to check if I'm already logged in #320

Closed icepuma closed 1 year ago

icepuma commented 1 year ago

Is your feature request related to a problem? Please describe. Hey, I want to create an integration with the doppler CLI. Therefore I want to check, if I'm already logged in.

Describe the solution you'd like I thought of having a dedicated doppler me command, which prints all the information about my login status.

Describe alternatives you've considered Is there already a mechanism I could use for that?

Additional context

No additional context.

icepuma commented 1 year ago

If you are happy with my suggestion, I would love to contribute the code! In the case you have an alternative suggestion, I would love to hear about it!

Best regards Stefan aka icepuma

nmanoogian commented 1 year ago

Hey @icepuma, cool idea! We don't have an API endpoint yet for fetching the current user so this solution would be a little bit more involved.

Would you be able to use doppler configure --json to fetch your active token? If you aren't logged in, that command will return an empty object.

icepuma commented 1 year ago

Yeah, the idea with doppler configure --json and getting the token would work! I think we can let this issue be open and implement the doppler me feature after you folks are done with the endpoint.

icepuma commented 1 year ago

I tested it and it works like a charm! Waiting for the doppler me command though.

nmanoogian commented 1 year ago

Great to hear! I'll share your idea with our product team, I think doppler me (and the corresponding API endpoint) could be useful in other contexts too

ryan-blunden commented 1 year ago

@icepuma If you wanted a temporary workaround, you could add something similar to your .bash_profile or .bashrc:

alias doppler-me='if doppler projects &>/dev/null ; then doppler configure --json; else echo "Doppler CLI unauthenticated"; fi'

Then just run doppler-me.

icepuma commented 1 year ago

I was hooking doppler - CLI into a another CLI via the ProcessBuilder from Rust. Therefore I wanted to have a clear interface via exit codes (= 0 -> logged in, > 0 -> not logged in). But the proposed workaround from @nmanoogian did work perfectly.