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

Fish completions with :4 and :0 as options #1279

Closed
caarlos0 opened this issue Nov 12, 2020 · 8 comments · Fixed by #1284
Closed

Fish completions with :4 and :0 as options #1279

caarlos0 opened this issue Nov 12, 2020 · 8 comments · Fixed by #1284

Comments

@caarlos0
Copy link
Contributor

We recently enabled completions on goreleaser, and it works pretty well.

One of the issues we found, though, is that on fish it returns :4 as an option, e.g.:

image

If I choose :4 and keep pressing TAB, it will keep completing :0 forever:

image

Same happens for subcommands, e.g.:

image

I think it might be related to the fact that we do some "hacky" stuff to make release be the default command instead of root (is there a better way of doing that?): https://github.com/goreleaser/goreleaser/blob/master/cmd/root.go#L30-L32

Anyway, not sure how much of this is a bug, how much is expected and how much is us doing things wrong.

@marckhouzam
Copy link
Collaborator

This sounds a lot like the problem described starting in this comment: #899 (comment)

I hope it helps.

@marckhouzam
Copy link
Collaborator

@caarlos0 did you find the problem?

@caarlos0
Copy link
Contributor Author

I have not 😔

@marckhouzam
Copy link
Collaborator

@caarlos0 I had a look. goreleaser always prints an empty line at the very end of its output:
https://github.com/goreleaser/goreleaser/blob/f35534d9d7cbc2d69fcbd4edb78a5d668357fa60/cmd/root.go#L23

I don't believe the completion script is ready for that. The completion script actually calls goreleaser __complete <args> (for example, for goreleaser completion <TAB> it will call goreleaser __complete completion "") and parses the output. But the script expects the last line to have a special meaning (the completion directive). In this case, the extra empty line confuses the script. Not sure why it works for zsh. I'll dig deeper and post a PR to handle this case.

Until there is a fix in Cobra, what you could do is avoid printing that empty line when the command is __complete.

@caarlos0
Copy link
Contributor Author

yes, that was it! I would never guess hehe

Thanks @marckhouzam 🚀

@marckhouzam
Copy link
Collaborator

Fix posted in #1284

@github-actions
Copy link

This issue is being marked as stale due to a long period of inactivity

@marckhouzam
Copy link
Collaborator

PR #1284 waiting for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants