spf13/cobra

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

marckhouzam opened this issue · 0 comments

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.