Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] completion for --help/--version #1786

Closed
silvioprog opened this issue Aug 23, 2022 · 1 comment · Fixed by #1813
Closed

[feature request] completion for --help/--version #1786

silvioprog opened this issue Aug 23, 2022 · 1 comment · Fixed by #1813
Labels
area/shell-completion All shell completions kind/bug A bug in cobra; unintended behavior

Comments

@silvioprog
Copy link

Hi.

It would be nice to allow the user to auto complete flags like --help, --version` etc.

For example, the git completion allows git --v[TAB] to auto complete to git --version.

TIA

@marckhouzam
Copy link
Collaborator

Agreed. I consider this a bug. I haven't looked at why the completion doesn't work for those flags but I feel it should.

@marckhouzam marckhouzam added kind/bug A bug in cobra; unintended behavior area/shell-completion All shell completions labels Aug 23, 2022
marckhouzam added a commit to marckhouzam/cobra that referenced this issue Sep 20, 2022
Fixes spf13#1786

The --help, -h, --version and -v flags are normally added when the
`execute()` function is called on a command.  When doing completion
we don't call `execute()` so we need to add these flags explicitly to
the command being completed.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
marckhouzam added a commit to marckhouzam/cobra that referenced this issue Oct 1, 2022
Fixes spf13#1786

The --help, -h, --version and -v flags are normally added when the
`execute()` function is called on a command.  When doing completion
we don't call `execute()` so we need to add these flags explicitly to
the command being completed.

Also, we disable all further completions if the 'help' or 'version'
flags are present on the command-line.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
marckhouzam added a commit to marckhouzam/cobra that referenced this issue Oct 1, 2022
Fixes spf13#1786

The --help, -h, --version and -v flags are normally added when the
`execute()` function is called on a command.  When doing completion
we don't call `execute()` so we need to add these flags explicitly to
the command being completed.

Also, we disable all further completions if the 'help' or 'version'
flags are present on the command-line.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
jpmcb pushed a commit that referenced this issue Oct 4, 2022
Fixes #1786

The --help, -h, --version and -v flags are normally added when the
`execute()` function is called on a command.  When doing completion
we don't call `execute()` so we need to add these flags explicitly to
the command being completed.

Also, we disable all further completions if the 'help' or 'version'
flags are present on the command-line.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/shell-completion All shell completions kind/bug A bug in cobra; unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants