buf: Zsh/Fish completion failing
Hi there,
zsh completion is not working, I’m getting _arguments:comparguments:325: invalid option definition: --log-format[The log format [text,color,json].]:
Generated completion looks like:
function _buf {
local -a commands
_arguments -C \
'--log-format[The log format [text,color,json].]:' \
'--log-level[The log level [debug,info,warn,error].]:' \
'--timeout[The duration until timing out.]:' \
"1: :->cmnds" \
"*::arg:->args"
It seems cobra doesn’t escape flag description properly: https://github.com/spf13/cobra/blob/v1.0.0/zsh_completions.go#L334 and braces from flag descriptions with permitted values break it.
I’m not sure whether it’s done on purpose for some flexibility or not.
% zsh --version
zsh 5.8 (x86_64-pc-linux-gnu)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (11 by maintainers)
This should be fixed - please let us know if this comes up again! We won’t be surprised 😃
Hey @marckhouzam, thanks for investigating this and all of the information! We’ve actually already patched this internally and it will go out with our next release We should have updated this issue when we landed the change internally, sorry about that.
The issue with both zsh and fish completion here is going to be within the github.com/spf13/cobra library - they’ve been doing a lot of refactors to shell completion recently https://github.com/spf13/cobra/commits/master and there’s clearly some bugs. Unfortunately, we don’t have the time to dive into these right now, but this is where the bug would be. Will keep this open, and will re-test as improvements in spf13/cobra are available.
@bufdev the error is fixed, but completion is gone now btw 😃 Didn’t have much time to figure out why, but generated code does nothing now, it doesn’t contain nether command names nor flags.