Skip to content

octopus completion powershell returns root help/banner instead of PowerShell completion script (exit code 3) #611

Description

@WillParry

The bug

The PowerShell autocomplete generation command appears to be broken in Octopus CLI 2.21.3 and 2.21.2.

The CLI advertises a completion command:

completion: Generate the autocompletion script for the specified shell

The following help command succeeds and shows the expected usage:

octopus help completion powershell

Output:

Generate the autocompletion script for powershell.

To load completions in your current shell session:

        octopus completion powershell | Out-String | Invoke-Expression

However, running the documented command:

octopus completion powershell

does not generate a PowerShell completion script.

Instead, it outputs the top-level Octopus CLI banner/help beginning with:

Work seamlessly with Octopus Deploy from the command line.

and exits with code:

3

No output is written to STDERR.

Because the command emits the root help text rather than a PowerShell script, the documented installation command also fails:

octopus completion powershell | Out-String | Invoke-Expression

Result:

Invoke-Expression : The term 'Work' is not recognized as the name of a cmdlet,
function, script file, or operable program.

Command to reproduce

octopus --version

octopus help completion powershell

octopus completion powershell

$LASTEXITCODE

Also:

octopus completion powershell | Out-String | Invoke-Expression

$LASTEXITCODE

Outcome

Actual:

Work seamlessly with Octopus Deploy from the command line.

                ####
            ############
         ##################
         ...

Exit code:

3

STDERR:

<empty>

Expected:

A PowerShell completion script is written to STDOUT.

Versions

cli:

2.21.3

Also reproduced on:

2.21.2

Octopus Server:

Not applicable

The completion script generation command should not require an Octopus Server connection to function.

Links

None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions