Open sunny0826 opened 2 years ago
Hi, I've tested the completion function using fish shell on MacOs X Monterey 12.2.1 with fish version: 3.3.1 on M1 chip. The completion nearly works but throw the following error:
'ompletion ended with directive: ShellCompDirectiveNoFileComp / 1' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 3 -eq 1 ^ ~/.config/fish/completions/kubecm.fish (line 93): if test $compErr -eq 1 ^ in function '__kubecm_prepare_completions' called on line 1 of file ~/.config/fish/completions/kubecm.fish in command substitution called on line 167 of file ~/.config/fish/completions/kubecm.fish from sourcing file ~/.config/fish/completions/kubecm.fish in command substitution math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 8' ^ math: Error: Unexpected token '% 2' ^ math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 16' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 3 -eq 1 ^ ~/.config/fish/completions/kubecm.fish (line 101): if test $filefilter -eq 1; or test $dirfilter -eq 1 ^ in function '__kubecm_prepare_completions' called on line 1 of file ~/.config/fish/completions/kubecm.fish in command substitution called on line 167 of file ~/.config/fish/completions/kubecm.fish from sourcing file ~/.config/fish/completions/kubecm.fish in command substitution test: Missing argument at index 3 -eq 1 ^ ~/.config/fish/completions/kubecm.fish (line 101): if test $filefilter -eq 1; or test $dirfilter -eq 1 ^ in function '__kubecm_prepare_completions' called on line 1 of file ~/.config/fish/completions/kubecm.fish in command substitution called on line 167 of file ~/.config/fish/completions/kubecm.fish from sourcing file ~/.config/fish/completions/kubecm.fish in command substitution math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 2' ^ math: Error: Unexpected token '% 2' ^ math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 4' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 3 -ne 0 ^ ~/.config/fish/completions/kubecm.fish (line 117): if test $nospace -ne 0; or test $nofiles -eq 0 ^ in function '__kubecm_prepare_completions' called on line 1 of file ~/.config/fish/completions/kubecm.fish in command substitution called on line 167 of file ~/.config/fish/completions/kubecm.fish from sourcing file ~/.config/fish/completions/kubecm.fish in command substitution test: Missing argument at index 3 -eq 0 ^ ~/.config/fish/completions/kubecm.fish (line 117): if test $nospace -ne 0; or test $nofiles -eq 0 ^ in function '__kubecm_prepare_completions' called on line 1 of file ~/.config/fish/completions/kubecm.fish in command substitution called on line 167 of file ~/.config/fish/completions/kubecm.fish from sourcing file ~/.config/fish/completions/kubecm.fish in command substitution math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 1' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 3 -eq 1 ^ ~/.config/fish/completions/kubecm.fish (line 93): if test $compErr -eq 1 ^ in function '__kubecm_prepare_completions' in command substitution math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 8' ^ math: Error: Unexpected token '% 2' ^ math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 16' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 3 -eq 1 ^ ~/.config/fish/completions/kubecm.fish (line 101): if test $filefilter -eq 1; or test $dirfilter -eq 1 ^ in function '__kubecm_prepare_completions' in command substitution test: Missing argument at index 3 -eq 1 ^ ~/.config/fish/completions/kubecm.fish (line 101): if test $filefilter -eq 1; or test $dirfilter -eq 1 ^ in function '__kubecm_prepare_completions' in command substitution math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 2' ^ math: Error: Unexpected token '% 2' ^ math: Error: Unknown function 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 4' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 3 -ne 0 ^ ~/.config/fish/completions/kubecm.fish (line 117): if test $nospace -ne 0; or test $nofiles -eq 0 ^ in function '__kubecm_prepare_completions' in command substitution test: Missing argument at index 3 -eq 0 ^ ~/.config/fish/completions/kubecm.fish (line 117): if test $nospace -ne 0; or test $nofiles -eq 0 ^ in function '__kubecm_prepare_completions' in command substitution
Let me know If you want me to do any test.
@interpeix Thank!!! Can you help to test whether cobra still has this problem after upgrading to version 1.4.0?
@sunny0826 Tested and still having the issue.
Builded using a clean Linux env and a fresh fish installation:
`vscode@a71fb1df192a /w/kubecm (dependabot/go_modules/github.com/spf13/cobra-1.4.0)> ./kubecm math: Error: Unexpected tokenish/completions/kubecm.fish 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 1' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 2
~/.config/fish/completions/kubecm.fish (line 93): if test $compErr -eq 1 ^ in function '__kubecm_prepare_completions' in command substitution
(Type 'help test' for related documentation) math: Error: Unexpected token 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 8' ^ math: Error: Unexpected token '% 2' ^ math: Error: Unexpected token 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 16' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 2
~/.config/fish/completions/kubecm.fish (line 101): if test $filefilter -eq 1; or test $dirfilter -eq 1 ^ in function '__kubecm_prepare_completions' in command substitution
(Type 'help test' for related documentation) test: Missing argument at index 2
~/.config/fish/completions/kubecm.fish (line 101): if test $filefilter -eq 1; or test $dirfilter -eq 1 ^ in function '__kubecm_prepare_completions' in command substitution
(Type 'help test' for related documentation) math: Error: Unexpected token 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 2' ^ math: Error: Unexpected token '% 2' ^ math: Error: Unexpected token 'ompletion ended with directive: ShellCompDirectiveNoFileComp / 4' ^ math: Error: Unexpected token '% 2' ^ test: Missing argument at index 2
~/.config/fish/completions/kubecm.fish (line 117): if test $nospace -ne 0; or test $nofiles -eq 0 ^ in function '__kubecm_prepare_completions' in command substitution
(Type 'help test' for related documentation) test: Missing argument at index 2
~/.config/fish/completions/kubecm.fish (line 117): if test $nospace -ne 0; or test $nofiles -eq 0 ^ in function '__kubecm_prepare_completions' in command substitution
(Type 'help test' for related documentation)`
The same results using MacOs
@interpeix Thanks a lot, I will create a new issue for this problem.
Hi, i noticed this issue is only for fish and powershell but I have some problems with completion also on zsh.
For example on tab after kubecm
I get that last option:
11:32 76% ❯ kubecm
add -- Add KubeConfig to $HOME/.kube/config
alias -- Generate alias for all contexts
clear -- Clear lapsed context, cluster and user
completion -- Generate completion script
create -- Create new KubeConfig(experiment)
delete -- Delete the specified context from the kubeconfig
help -- Help about any command
list -- List KubeConfig
merge -- Merge the KubeConfig files in the specified directory
namespace -- Switch or change namespace interactively
rename -- Rename the contexts of kubeconfig
switch -- Switch Kube Context interactively
version -- Print version info
:4 Completion ended with directive: ShellCompDirectiveNoFileComp
It also happen with any other commands but the error is sometime different:
11:32 76% ❯ kubecm list
:0 Completion ended with directive: ShellCompDirectiveDefault
I enabled the completion with kubecm completion zsh > "${fpath[1]}/_kubecm"
and zsh version is zsh 5.8 (x86_64-ubuntu-linux-gnu)
, don't know if it matters but I also use oh-my-zsh.
Hi, i noticed this issue is only for fish and powershell but I have some problems with completion also on zsh. For example on tab after
kubecm
I get that last option:11:32 76% ❯ kubecm add -- Add KubeConfig to $HOME/.kube/config alias -- Generate alias for all contexts clear -- Clear lapsed context, cluster and user completion -- Generate completion script create -- Create new KubeConfig(experiment) delete -- Delete the specified context from the kubeconfig help -- Help about any command list -- List KubeConfig merge -- Merge the KubeConfig files in the specified directory namespace -- Switch or change namespace interactively rename -- Rename the contexts of kubeconfig switch -- Switch Kube Context interactively version -- Print version info :4 Completion ended with directive: ShellCompDirectiveNoFileComp
It also happen with any other commands but the error is sometime different:
11:32 76% ❯ kubecm list :0 Completion ended with directive: ShellCompDirectiveDefault
I enabled the completion with
kubecm completion zsh > "${fpath[1]}/_kubecm"
and zsh version iszsh 5.8 (x86_64-ubuntu-linux-gnu)
, don't know if it matters but I also use oh-my-zsh.
@gpstuff thx for your feedback. I have created a new issue to track this issue.
The shell completions for
fish
andPowerShell
have been added in v0.16.2, but I don't have the appropriate environment to test if they work. If you are usingkubcm
and are usingfish
orPowerShell
, please help to test if this feature is available. Please provide feedback in this issue, thank!