Skip to content

Completion should not complete the --help/-h and --version/-v flags if DisableFlagParsing==true  #2060

Closed
@marckhouzam

Description

@marckhouzam

When a command sets DisableFlagParsing = true it requests the responsibility of doing all the flag parsing.
If there are flags for that command, Cobra may not even know about them.
I've seen this used to provide plugins to a Cobra-based CLI. The plugins must handle their own flags as the original CLI knows nothing about such flags.

The problem is that with #1813 the shell completion logic completes the --help/-h and --version/-v for all commands, even those that do their own flag handling (i.e., DisableFlagParsing == true). I've seen this cause the --help/-h be completed twice for plugins: one time from cobra and one time from the plugin.

I therefore feel that Cobra should not complete the --help/-h and --version/-v if DisableFlagParsing==true.

Somewhat related to #1328 but for completion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions