Skip to content

Support for completion in other shells (fish, sh, etc.) #351

Closed

Description

@hasit

Hello,

I was going through the repo (I am using cli for my new project) and I found that it supports generation of bash and zsh completion files automatically. That is pretty amazing. Is there a way to support other shells (e.g. fish, sh)? I am an avid fish shell user and have been using it since a long time.

I would like to propose implementation of EnableCompletion flag instead of EnableBashCompletion flag to accept a string for supported shells (like bash, zsh, fish, sh, ...) and generate autocomplete file for the mentioned shell.

If it is a desirable feature, I would like to brainstorm the implementation with the author and community members and take the initial steps towards its development.

Activity

  1. changed the title [-]Fish completions[/-] [+]Support for completion in other shells (fish, sh, etc.)[/+] on Apr 8, 2016
  2. jszwedko commented on Apr 9, 2016

    @jszwedko
    Contributor

    Hi @hasit!

    I think it would be great to support fish and other shells. I think your proposed change to the interface makes sense. I'd be happy to discuss further and review any pull requests introducing this.

  3. hasit commented on Apr 10, 2016

    @hasit
    Author

    Thank you @jszwedko.

    To start off, I forked the repo and started reading the App interface and how it accepts parameters. My question is, how does EnableBashCompletion bool variable translate into generating autocomplete file? I do not see a function that is doing that. It'd be very helpful if you could explain the flow from the point of setting to generation of the autocomplete file.

    To aid this enhancement, I would like to add

    • In type App struct, change EnableBashCompletion bool -> EnableCompletion bool to accommodate all (supported) shells.
    • In type App struct, add CompletionShells []string to accept which shell completion scripts the user wants to generate. For example, when writing a program in Go using cli, the user can write
    ...
    app.EnableCompletion = true
    app.CompletionShells = []string{"zsh", "fish", "bash"}
    …

    and cli will generate autocompletion scripts for all three shells.

  4. jszwedko commented on Apr 20, 2016

    @jszwedko
    Contributor

    Hi @hasit!

    We'll want to maintain (but deprecate) EnableBashCompletion to support backwards compatibility for now, but I think your suggested fields make sense. We could simplify slightly and just do CompletionShells (if it is empty disable).

    As far as for the current flow, it looks something like:

    Currently this only works for subcommands, but could be expanded to handle flags.

    Let me know if this makes things clearer!

  5. added
    kind/feature
    on Apr 28, 2016
  6. saschagrunert commented on Aug 3, 2019

    @saschagrunert
    Member

    I would like to bring this topic back in the table, because I think a fish completion should be doable relatively straight forward via code generation. WDYT?

  7. coilysiren commented on Aug 3, 2019

    @coilysiren
    Member

    I absolutely think we can add fish completion! It should be an easy PR to add into the 1.X series 👍

  8. added
    help wanted
    status/confirmed
    on Aug 3, 2019
  9. added
    area/v2
    on Nov 27, 2019
  10. stale commented on Feb 25, 2020

    @stale

    This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.

  11. added
    status/stale
    on Feb 25, 2020
  12. 6 remaining items

  13. tionis commented on Jun 14, 2021

    @tionis

    This should still be very relevant. Can I bump this?

  14. reopened this on Jun 15, 2021
  15. stale commented on Jun 15, 2021

    @stale

    This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant.

  16. removed
    status/stale
    on Jun 15, 2021
  17. added
    area/v3
    and removed
    area/v2
    on Oct 30, 2022
  18. added
    status/claimed
    on Nov 29, 2022
  19. dearchap commented on Nov 29, 2022

    @dearchap
    Contributor

    It appears that fish completion was already added in 2.x. Do we want to keep the dynamic auto complete feature in cli or move to a generated one like what kubectl does.

    kubectl completion fish | source
    
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

    area/v3help wantedkind/featurestatus/claimedstatus/confirmed

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions