Easily switch between multiple credentials for a single CLI tool.
op CLI version
2.12.0
Goal or desired behavior
There are several cases where I manage different credential sets for the same CLI command.
For example, I manage over 180 AWS accounts (I use AWS Vault for this and am not planning on switching, but it makes for a good example.)
I have read-only + admin tokens for both GitHub.com as well as multiple GitHub Enterprise users. If I'm using the gh command, switching between them should be easy.
Current behavior
Unknown. I can't tell if/how this is supported.
Relevant log output
N/A
Just wanted to share my interest for this ability as well. Right now, the only way to switch to another credential is to first run op plugin clear plugin-name followed by any command for that plugin, thus being prompted to choose the credential again.
I ran into the need for this ability when building the Fastly shell plugin:
- https://github.com/1Password/shell-plugins/pull/169
A variant of the [needsauth.Always()](https://github.com/1Password/shell-plugins/blob/d4822d5ebb3ddf2d633316e1a2f06852bebccaf5/sdk/needsauth/helpers.go#L55-L59) helper function would be nice. For example, in the Fastly CLI case, any command starting with fastly profile could prompt the user to choose the credential before executing the rest of the command. Example code:
NeedsAuth: needsauth.IfAll(
needsauth.Always(
needsauth.ForCommand("profile"),
),
),
The ability to specify a secret name directly on the cli when executing would be amazing.
op plugin run --secret "Account/Vault/secret" -- aws
I would love to have this for picking a database environment (e.g. local, dev, staging, etc.) when using pgcli. Maybe if the plugin has been init'd with multiple credentials it can prompt to choose one instead of just using the most recently selected credential?