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 completion not working #486

Closed
erazemk opened this issue Oct 29, 2020 · 19 comments
Closed

Fish completion not working #486

erazemk opened this issue Oct 29, 2020 · 19 comments

Comments

@erazemk
Copy link

erazemk commented Oct 29, 2020

Fish completion for git-bug doesn't seem to work for me.
Since it wasn't even listed in the readme I assumed there wasn't a completion script available and have started working on my own version, but then I found it in the repository.

Is the script just a work in progress or should it work properly and this is an actual bug?

@MichaelMure
Copy link
Owner

Are you using the one from the released version or from master? Completion scripts are generated by the library handling the CLI commands, cobra. They recently updated the fish generation IIRC.

@erazemk
Copy link
Author

erazemk commented Oct 29, 2020

Are you using the one from the released version or from master?

The released version (git-bug v0.7)

Completion scripts are generated by the library handling the CLI commands, cobra. They recently updated the fish generation IIRC.

Ok, I'll try the master branch.

@erazemk
Copy link
Author

erazemk commented Oct 29, 2020

Still doesn't work when built from the latest master branch.
Would it make sense to manually maintain the completion?

Edit: Looks like the command completion might be working, just not for subcommands, since it does complete --help when typing git bug -. While on the subject, the bash completion for subcommands (and for --help) also doesn't work for me, so it could be a problem on my end or the latest commit from cobra could have broken something.

@MichaelMure
Copy link
Owner

Could you try if it works for git-bug instead of git bug? A little wrapper had to be written for bash.

@erazemk
Copy link
Author

erazemk commented Oct 29, 2020

Could you try if it works for git-bug instead of git bug? A little wrapper had to be written for bash.

Doesn't work for me (neither bash nor fish).

@erazemk
Copy link
Author

erazemk commented Oct 29, 2020

Do completions work on your PC?

@MichaelMure
Copy link
Owner

Completion for bash works, but I never used fish. There might be extra steps to take for fish: https://github.com/spf13/cobra/blob/master/shell_completions.md

@erazemk
Copy link
Author

erazemk commented Oct 29, 2020

There might be extra steps to take for fish

You mean on the user's side or on the cobra side? Because completion for other commands works without specific configuration.

@MichaelMure
Copy link
Owner

I was thinking git-bug/cobra side, but I only skimmed this document.

@erazemk
Copy link
Author

erazemk commented Oct 29, 2020

I was thinking git-bug/cobra side, but I only skimmed this document.

Hmm, I haven't used cobra before so I don't think I'll be able to do much here.
Since this probably won't get updated until someone contributes to it, should we close the issue?

@MichaelMure
Copy link
Owner

I mean, the fish completion of cobra is supposed to work, but there might be extra things to do on git-bug's command to have proper completion. if that doesn't work for you, something should be done.

@erazemk
Copy link
Author

erazemk commented Oct 29, 2020

I mean, the fish completion of cobra is supposed to work, but there might be extra things to do on git-bug's command to have proper completion. if that doesn't work for you, something should be done.

Fair enough, thanks :)

@krobelus
Copy link
Contributor

Looks like the command completion might be working, just not for subcommands, since it does complete --help when typing git bug -

That's fish's stock git completion.

After doing source misc/fish_completion/git-bug, completions for the literal git-bug command should work.
For example git-bug brid<TAB> should complete. However, I get an error with the script on master.
I might take a look. One problem is that - is not valid in fish's variable names. Probably an easy fix in Cobra.

set: Variable name '__git-bug_comp_do_file_comp' is not valid. See `help identifiers`.

misc/fish_completion/git-bug (line 55):
    set --erase __git-bug_comp_do_file_comp
    ^

Since fish-shell/fish-shell#7075 (in the upcoming 3.2.0 release) fish automatically loads completions for git-foo if git-foo.fish exists in $fish_complete_path. Then completions for git bug should also work (assuming the other error is fixed). Also then there is no need to manually source it, it will be when the user types git bug.

@MichaelMure
Copy link
Owner

Thanks @krobelus, that's very helpful.

@MichaelMure
Copy link
Owner

@krobelus could you open an issue for that problem at https://github.com/spf13/cobra? Looks like it could be easily fixed.

@krobelus
Copy link
Contributor

krobelus commented Oct 31, 2020

Turns out this is already fixed in Cobra v1.1.0 (via spf13/cobra#1122).
I tested with the current Cobra v1.1.1, the completions work fine after a go generate.

@MichaelMure
Copy link
Owner

I'm a bit confused, current master does use cobra v1.1.1 and the completion script doesn't change after a go generate Were you just using an older master?

@krobelus
Copy link
Contributor

krobelus commented Nov 1, 2020

OMG, my bad, I was on an old version indeed. This can be closed.

To sum up, when using the development version you can do this to enable fish completions:

cp misc/fish_completion/git-bug ~/.config/fish/completions/git-bug.fish

OS-specific packages should already do that. I'm not sure if there is an accepted way for go install to install such support files.

@MichaelMure
Copy link
Owner

Well, to be fair, I merged that PR 5 days ago, that's easy to miss.

go install will only care about the go binary, it's not meant to be a complete way to install something. The makefile could be smarter but let's not try to re-implement the autotools. This should be left to packagers imho (although a better user installation doc would be nice).

BTW, I believe the fish completion could be made much nicer by tackling #493

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

No branches or pull requests

3 participants