Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

saschagrunert
Copy link
Member

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?

@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 26, 2019
@openshift-ci-robot
Copy link
Collaborator

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 26, 2019
@vrothberg
Copy link
Member

/ok-to-test
/approve

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 26, 2019
@openshift-ci-robot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2019
@vrothberg
Copy link
Member

Thanks a lot, @saschagrunert!

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?

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.

Copy link
Member

@vrothberg vrothberg left a 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.

Makefile Outdated Show resolved Hide resolved

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
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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 👍

@TomSweeneyRedHat
Copy link
Member

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.

@saschagrunert
Copy link
Member Author

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>
@edsantiago
Copy link
Collaborator

edsantiago commented Mar 26, 2019

@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.

And, incidentally, you will need to update contrib/spec/podman.spec.in to get CI to pass. (never mind; I just saw your new force-push)

@saschagrunert
Copy link
Member Author

@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

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 27, 2019
@saschagrunert
Copy link
Member Author

@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... 😟

@edsantiago
Copy link
Collaborator

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.

@saschagrunert
Copy link
Member Author

I will close this for now and will follup up on this topic in the future.

@saschagrunert saschagrunert deleted the fish-completion branch April 3, 2019 07:12
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants