You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for completion in other shells (fish, sh, etc.) #351
area/v3relates to / is being considered for v3help wantedplease help if you can!kind/featuredescribes a code enhancement / feature requeststatus/claimedsomeone has claimed this issuestatus/confirmedconfirmed to be valid, but work has yet to start
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.
Reacted by Jan Niklas Hasse, Vikas Kedia, Hans-Christian Otto, Futa HIRAKOBA, Filip Strozik and Ben
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.
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
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:
Programmer enables bash completion via EnableBashCompletion
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?
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.
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.
area/v3relates to / is being considered for v3help wantedplease help if you can!kind/featuredescribes a code enhancement / feature requeststatus/claimedsomeone has claimed this issuestatus/confirmedconfirmed to be valid, but work has yet to start
Activity
[-]Fish completions[/-][+]Support for completion in other shells (fish, sh, etc.)[/+]jszwedko commentedon Apr 9, 2016
Hi @hasit!
I think it would be great to support
fishand 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.hasit commentedon Apr 10, 2016
Thank you @jszwedko.
To start off, I forked the repo and started reading the
Appinterface and how it accepts parameters. My question is, how doesEnableBashCompletionbool 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
type App struct, changeEnableBashCompletion bool -> EnableCompletion boolto accommodate all (supported) shells.type App struct, addCompletionShells []stringto accept which shell completion scripts the user wants to generate. For example, when writing a program in Go usingcli, the user can writeand
cliwill generate autocompletion scripts for all three shells.jszwedko commentedon Apr 20, 2016
Hi @hasit!
We'll want to maintain (but deprecate)
EnableBashCompletionto support backwards compatibility for now, but I think your suggested fields make sense. We could simplify slightly and just doCompletionShells(if it is empty disable).As far as for the current flow, it looks something like:
EnableBashCompletion/etc/bash_completion.d/<program name>(this would commonly be done by a package or install script)--generate-bash-completioncodegangsta/cliintercepts this and callsBashCompletewhich defaults toDefaultAppComplete(https://github.com/codegangsta/cli/blob/bc465becccd1d527002fda095fc3c19d9c115029/help.go#L119-L125)Currently this only works for subcommands, but could be expanded to handle flags.
Let me know if this makes things clearer!
saschagrunert commentedon Aug 3, 2019
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?
coilysiren commentedon Aug 3, 2019
I absolutely think we can add fish completion! It should be an easy PR to add into the 1.X series 👍
Merge master @1.22.1 with v2
Merge master @1.22.1 with v2
Merge latest master into v2-merge-master
stale commentedon Feb 25, 2020
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.
6 remaining items
tionis commentedon Jun 14, 2021
This should still be very relevant. Can I bump this?
stale commentedon Jun 15, 2021
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.
dearchap commentedon Nov 29, 2022
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.