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?
Michael Muré (MichaelMure) commented
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.
Erazem Kokot (erazemk) commented (edited)
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.
Erazem Kokot (erazemk) commented (edited)
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.
Michael Muré (MichaelMure) commented
Could you try if it works for git-bug instead of git bug? A little wrapper had to be written for bash.
Erazem Kokot (erazemk) commented
Could you try if it works for git-bug instead of git bug? A little wrapper had to be written for bash.
You mean on the user's side or on the cobra side? Because completion for other commands works without specific configuration.
Michael Muré (MichaelMure) commented
I was thinking git-bug/cobra side, but I only skimmed this document.
Erazem Kokot (erazemk) commented
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?
Michael Muré (MichaelMure) commented
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.
Erazem Kokot (erazemk) commented
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 :)
Johannes Altmanninger (krobelus) commented
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 https://github.com/fish-shell/fish-shell/pull/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.
Michael Muré (MichaelMure) commented
Thanks @krobelus, that's very helpful.
Michael Muré (MichaelMure) commented
@krobelus could you open an issue for that problem at https://github.com/spf13/cobra? Looks like it could be easily fixed.
Johannes Altmanninger (krobelus) commented (edited)
Turns out this is already fixed in Cobra v1.1.0 (via https://github.com/spf13/cobra/pull/1122).
I tested with the current Cobra v1.1.1, the completions work fine after a go generate.
Michael Muré (MichaelMure) commented
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?
Johannes Altmanninger (krobelus) commented
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:
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.
Michael Muré (MichaelMure) commented
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).