Repository navigation
Conversation
Shell completion has offered context names as the argument to `doctl auth switch` and `doctl auth remove` since #1044, but neither command read it. `doctl auth switch work` reported "Now using context [default]" and left the current context in place; `doctl auth remove work` failed with "You must provide a context name". Both commands now take the context as their argument as well as with --context. Naming two different contexts, or passing more than one argument, is an error. Completion also lists each context once and in a stable order, and the auth commands that take no argument no longer complete file names. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
the usage strings switch and remove read as if the name is required in that position. Square brackets would match how these commands actually behave: switch [name] and remove [name]. doctl auth switch works with no name and keeps the current context, and both commands still accept --context. The long help already explains that |
The name can be omitted when --context is set, and switch with neither keeps the current context. Co-authored-by: Cursor <cursoragent@cursor.com>
SSharma-10
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shell completion has offered context names as the argument to
doctl auth switchanddoctl auth removesince #1044, but neither command ever read an argument; they only look at--context. So accepting a suggestion did the wrong thing:The silent no-op on
switchwas first reported in #659. A customer hit it again recently.Changes
switchandremovetake the context as their argument, as well as with--context. Naming two different contexts, or passing more than one argument, is an error.defaultonce (it was suggested twice oncedefaultwas inauth-contexts) and the rest in sorted order (they came from a map, so the order changed between presses). Names are no longer suggested after--contexthas been given.init,login,listandtokenno longer fall back to completing file names.doctl auth switch <name>/doctl auth remove <name>.Testing
TestAuthSwitchAndRemoveTakeContextArgument,TestGetAuthContextList.go test ./commands/ -run 'TestAuth|TestGetAuthContextList|Test_displayAuthContexts'andgo test ./integration/ -run 'TestRun/doctl/auth'pass.auth switch microdroplet-previewauth switch --context microdroplet-previewauth switch microdroplet-preview --context defaultauth switch a bauth remove microdroplet-preview__complete auth switch ""default,microdroplet-preview(once each)__complete auth token ""