Support configuring new auth context without interactivity
In some cases, it can be useful to configure doctl non-interactively. Currently, we support this when setting up the default context. For example, running the following will validate the token and add it to the doctl config file without additional user interaction:
doctl auth init -t $DO_TOKEN
Using token [asupersekrettokenthatisverylongidontwanttotypeit]
Validating token... OK
If the --context flag is added to that command, the token is ignored and the user is prompted to enter the token manually:
doctl auth init --context new-context -t $DO_TOKEN
DigitalOcean access token:
The behaviour should be consistent. When passing a token and a context together to doctl auth init, we should validate the token and configure a new context to use it without additional user input.
It works ok when using -t flag but not when using the long version of the flag (--access-token) Using doctl v1.75
Also, not working when adding the flag for the context
doctl auth init --context new-context -t $DO_TOKEN
Encountered this today working in a GitLab CI environment.
Had to play around locally with the digitalocean/doctl:1.92.0 Docker image to find out that indeed this was the behavior.