-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[RFC] Redirect bash completion v1 to v2 when possible #1867
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ok with the change but I wonder what the motivation is? Assuming that you will not remove the old script until a major version bump I don't see the benefit.
I should have explained in the PR description, sorry. Basically I'm trying to improve the quality of bash completion for projects using Cobra. I don't think it is easy for projects to know that there is such a thing as a V2 version and therefore I feel projects are missing out on bug fixes and features. But maybe this is overreaching. I'd like people's honest opinion on this and if there is too much hesitation, we'll just close it. |
We are no longer actively maintaining bash completion v1 in favor of its more rich v2 version. Previously, using bash completion v2 required projects to be aware of its existence and to explicitly call GenBashCompletionV2(). With this commit, any projects calling GenBashCompletion() will automatically be redirected to using the v2 version. One exception is if the project uses the legacy custom completion logic which is not supported in v2. We can detect that by looking for the use of the field `BashCompletionFunction` on the root command. Note that descriptions are kept off when calling GenBashCompletion(). This means that to enable completion descriptions for bash, a project must still explicitly call GenBashCompletionV2(). Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
c16ca97
to
5a79329
Compare
I think it is a good idea overall. IMO there shouldn't be a reason to use the V1 version but then again I don't really know how and where is is used. One thing that we can do without changing behaviour is to add a |
Seems fine to me too. |
The Cobra project currently lacks enough contributors to adequately respond to all PRs. This bot triages issues and PRs according to the following rules:
|
We are no longer actively maintaining bash completion v1 in favor of its more rich v2 version. Previously, using bash completion v2 required projects to be aware of its existence and to explicitly call
GenBashCompletionV2()
.With this commit, any projects calling
GenBashCompletion()
will automatically be redirected to using the v2 version.One exception is if the project uses the legacy custom completion logic which is not supported in v2. We can detect that by looking for the use of the field
BashCompletionFunction
on the root command.If we ignore the tests and doc, this is a 2 line change in
bash_completions.go
Note that descriptions are kept off when calling
GenBashCompletion()
. This means that to enable completion descriptions for bash, a project must still explicitly callGenBashCompletionV2()
. I chose this approach because I was hesitant to enable descriptions without getting projects to make the decision themselves.cc @jpmcb @scop @Luap99