Fix: allow completion command to run without an Octopus login#612
Draft
HuyPhanNguyen wants to merge 1 commit into
Draft
Fix: allow completion command to run without an Octopus login#612HuyPhanNguyen wants to merge 1 commit into
HuyPhanNguyen wants to merge 1 commit into
Conversation
The completion command and cobra's __complete/__completeNoDesc helpers require a client factory, so shell completion fails with exit 3 when the user is not logged in. Add them to commandDoesNotRequireClient since they are purely local and never contact the server.
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.
Background
octopus completion <shell>is a local Cobra command that prints a shell completion script; it never contacts the server. ButcommandDoesNotRequireClientincmd/octopus/main.godoesn't include it, so when the user hasn't runoctopus loginthe client factory fails to build and the CLI exits with code 3, printing the config banner to stdout instead of the script. Piping that intoInvoke-Expressionthen fails withThe term 'Work' is not recognized. The same gap hits Cobra's hidden__complete/__completeNoDeschelpers, which the shell calls on every Tab press — so completions stay broken when not logged in even after installing them.Results
Adds
completion,__complete, and__completeNoDesctocommandDoesNotRequireClientso completion works without a login.Fixes FD-555
Fixes #611
Before
Not logged in:
octopus completion powershell | Out-String | Invoke-Expression→The term 'Work' is not recognized.After
Not logged in:
octopus __complete ""also returns the command list (exit 0) instead of failing.Testing
commandDoesNotRequireClient.completion powershelland__completenow exit 0; the... | Out-String | Invoke-Expressioncommand runs clean.