To make browsing issues easier it would be really great if we could have shell completion on par with git completion in zsh (not sure how well it works in bash). Ideally typing git bug show <TAB> would show a list of bugs similar to how git checkout <TAB> shows a list of branches and commits (see picture).
There is a PR open for that but the author is on hold for personal reason.
Aleksandra Glesaaen ĂdegĂ„rd (Irubataru) commented
I see, interesting. I sort of assumed that shell completion was handled by separate completion scripts, but I guess it makes sense that you use the git-bug executable to handle lookup of the information that zsh etc would need.
Aleksandra Glesaaen ĂdegĂ„rd (Irubataru) commented
Sorry for the late reply, but I finally got around to trying it out and when I try to autocomplete git bug show I get the following message:
_arguments:comparguments:325: invalid option definition: (-f --field)-f[Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]]:
_arguments:comparguments:325: invalid option definition: (-f --field)-f[Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]]:
_arguments:comparguments:325: invalid option definition: (-f --field)-f[Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]]:
and if I try to tab complete git bug ls then I get
_arguments:comparguments:325: invalid option definition: (*-s *--status)*-s[Filter by status. Valid values are [open,closed]]:
_arguments:comparguments:325: invalid option definition: (*-s *--status)*-s[Filter by status. Valid values are [open,closed]]:
_arguments:comparguments:325: invalid option definition: (*-s *--status)*-s[Filter by status. Valid values are [open,closed]]:
I installed it wit the go get method, and placed the git-bug file in the folder you linked somewhere my zsh instance could find it.
Unfortunately, I have zero knowledge about ZSH completion. Would you be able to fix that ?
Aleksandra Glesaaen ĂdegĂ„rd (Irubataru) commented (edited)
I tried with both git-bug and git bug, and it makes no difference, so I don't think that is the issue. I think I found it though, it appears to be due to the brackets in the explanation strings, e.g. as you can see in line 141.
I use zsh, but I have never tried to write completion for it. However, if you escape the inner brackets as \[ and \] then I do not get those error messages anymore. I thought about making a quick PR for it, but it appears that you generate the completion scripts from go, so maybe you have to fix it at a different level.
Also, there is no completion for completing issue numbers. If you look at the zsh file and the bash file, you can see that the bash file has a lot more logic in it. The zsh file only completes command names and optional argument strings. I played around with it for a bit and got something basic working, so maybe I could help out with that if I ever find the time, or is that something your framework should support by itself?
The situation is that git-bug use Cobra as the command line parser, and this library can generate the ZSH completion. They just landed a complete rewrite of this, so it's possible there is a bug lurking somewhere. The code generating the file is there: https://github.com/spf13/cobra/blob/master/zsh_completions.go
That said, it's very much in line with what they want to support (it's possible for bash). git-bug has the ls-id command so it would be pretty easy to plug there. Note though that all te git-bug commands support giving a simple prefix, so you don't need that much the completion.