Skip to content

Completion for shells supported by cobra #8109

Closed

Description

@kri5

I took a quick look at the code handling completion in the helm command, and there seems to be a slight issue with renamed binaries, where the generated completion would not have a proper name.

Nowadays fish completion is derivated from the bash one, and there is a bash snippet in case the binary has been renamed from the default.

A Better way of handling it might be to pass the binary name as the name passed when creating the Root cobra command, and so it will propagate everywhere else.

Feel free to comment on this, and i'll try to make a PR to implement this

Activity

  1. hickeyma commented on May 13, 2020

    @hickeyma
    Contributor
  2. added
    bug
    on May 13, 2020
  3. marckhouzam commented on May 13, 2020

    @marckhouzam
    Member

    Thanks for your interest @kri5!

    Nowadays fish completion is derivated from the bash one, and there is a bash snippet in case the binary has been renamed from the default.

    A Better way of handling it might be to pass the binary name as the name passed when creating the Root cobra command, and so it will propagate everywhere else.

    When I originally added the bash snippet, I had played around with passing a different binary name to cobra. But there are other consequences to that. For example, the help messages and error messages would now use the new binary name, IIRC. Then I got worried that it may cause some other side-effect that I wasn't aware of. I felt that kind of change would make the maintainers justifiably nervous, so I decided to isolate the change into the completion script alone.

    What is you scenario for renaming the binary? Is it helm v2 vs helm v3? I'm asking because it may be better to try to make cobra officially support such a renaming.

    What do you think?

  4. kri5 commented on May 13, 2020

    @kri5
    Author

    I think you are right.

    As you can see in #8111 i went for what i previously proposed at first, ie changing to the name of the binary when creating the cobra command, but coverage tests on the PR failed because of what you expected.

    Many tests hardcodes the 'helm' binary names, so i went to the approach you mentionned where i change the binary name in the command just before using it for completion, to narrow down the scope of my changes.

    I have no scenario for that but a comment in the code that seemed to be related to installation of helm2 and helm3 at the same time.

    I took a look at cobra and basically the public API use for completion is basically just a thin wrapper getting the name of the command and passing it to an underlying function that takes the name as parameter, so there might be room for discussion on the cobra side.

  5. github-actions commented on Aug 21, 2020

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  6. marckhouzam commented on Aug 21, 2020

    @marckhouzam
    Member

    Work is ongoing for this.
    There's pr #8111 to add fish completion.

    As for zsh, we are waiting for a new Cobra release before we can use cobra's native zsh completion. The latest Cobra release (1.0.0) does not offer sufficient support for zsh completion for helm to use it.

  7. github-actions commented on Nov 20, 2020

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  8. marckhouzam commented on Nov 20, 2020

    @marckhouzam
    Member

    We can mark this as done: helm 3.4 now has fish completion and helm 3.5 will have native zsh completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions