-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add fish shell completion #2764
Conversation
Hi @saschagrunert. Thanks for your PR. I'm waiting for a containers or openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: saschagrunert, vrothberg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks a lot, @saschagrunert!
I see one issue with auto-generating those from cobra, namely that it doesn't work for argument completions but only for commands, sub-commands, flags, and options. But we also need to complete image names, containers names, pods, etc.; any kind of completion that requires semantic knowledge. I think auto-generated files are nice as a starting point, but I don't think we can avoid manual maintenance afterward. |
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.
One nit, otherwise LGTM.
3caad1b
to
b04247b
Compare
completions/fish/podman.fish
Outdated
|
||
function __fish_podman_no_subcommand --description 'Test if podman has yet to be given the subcommand' | ||
for i in (commandline -opc) | ||
if contains -- $i attach build commit container cp create diff events exec export generate generate-completion healthcheck history image images import info inspect kill load login logout logs mount pause play pod port ps pull push restart rm rmi run save search start stats stop system tag top umount unpause varlink version volume wait |
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.
maybe I've missed something, but is 'generate-completion' valid?
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.
Oh, I think I see now, it's for the shell completions itself, not necessarily a podman command.
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.
Yeah, sorry I forgot to remove it after my modification of podman 👍
The changes LGTM, but I'm very concerned about manually maintaining podman.fish over time. I can just see it getting out of step too quickly. I'd feel more comfortable with it if podman.fish could be created reliably in a make process based on the Cobra settings. Definitely want @mheon, @rhatdan and @baude to chime in on this one. |
b04247b
to
00ff62e
Compare
We could wait for this one spf13/cobra#754 and then add necessary fish functions for the completion of, for example, image names. Then we would have an auto-generated and manually maintained part of the completion. |
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
00ff62e
to
70fb22c
Compare
@saschagrunert have you looked at the zsh completion code? That's almost entirely self-discovering, using `podman --help', with a few extensions for determining image/container/volume/registry names. Perhaps something like that could be done with fish as well? As others have mentioned, hardcoding every option is not maintainable.
|
Yeah I also thought about an on-the-fly parser, but in the end I see pros and cons for both kinds of solutions. Let me elaborate how such a parser can be implemented and then come back with my findings. /hold |
@edsantiago I played around with some scripted (sed-based) approach in fish shell and must say it is damn slow (some seconds) compared to a generated file. I really would like to recommend in generating the completion grammatically and injecting necessary static functions as constant strings. The generation of the shell completion could then be done via some make target. WDYT? I guess since the related PR in fish shell is not merged this can't be done here, too... 😟 |
Autogenerating a completion file at build time was actually my first approach; I abandoned it for several reasons including the difficulty of validating the generated results. I have to assume that your PR is mostly autogenerated; if you can come up with a reliable script that will run at build time, using only tools that are available on build systems, I'd be much more inclined to accept it enthusiastically. Thank you again for your efforts on this. |
I will close this for now and will follup up on this topic in the future. |
Hey there, I added the fish shell completion to podman. I also thought about adding an auto generation (cobra supports it for zsh, bash and (soon) for fish) subcommand, that the files don't have to be manually maintained. What do you think?