cobra
cobra copied to clipboard
fix: quote args in fish shell completion
The arguments used for dynamic completions in fish were missing quotes. This resulted in an error when one of the arguments had a * in it whose expansion matched no file. Once the completion got triggered, fish errored with the message No matches for wildcard [...]. Don't quote the first argument as that is the name of the binary.
Closes #1933
This seemed reasonable but when I run the tests in https://github.com/marckhouzam/cobra-completion-testing I'm getting failures. I haven't investigated yet.
I pushed a commit on top of the PR to properly handle when the arguments are flags.
The the problem was that when completing something like "prog --hello <TAB>" the new string join and string escape commands in the fish scripts would receive --hello and would treat it as a flag instead of an argument. By using string join -- and string escape -- we tell fish that all arguments following the -- are not to be treated as flags.