Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help Wanted] Test completions command #76

Open
sunny0826 opened this issue Nov 15, 2021 · 6 comments
Open

[Help Wanted] Test completions command #76

sunny0826 opened this issue Nov 15, 2021 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@sunny0826
Copy link
Owner

sunny0826 commented Nov 15, 2021

The shell completions for fish and PowerShell have been added in v0.16.2, but I don't have the appropriate environment to test if they work. If you are using kubcm and are using fish or PowerShell, please help to test if this feature is available. Please provide feedback in this issue, thank!

The shell completions feature is a function that allows the user to use the <TAB> key to automatically complete commands when using kubecm, and will not affect the normal use of kubecm if this feature is not available.

@sunny0826 sunny0826 added the help wanted Extra attention is needed label Nov 15, 2021
@sunny0826 sunny0826 pinned this issue Nov 15, 2021
@interpeix
Copy link

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.

@sunny0826
Copy link
Owner Author

@interpeix Thank!!! Can you help to test whether cobra still has this problem after upgrading to version 1.4.0?

refer: #257

@interpeix
Copy link

@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

@sunny0826
Copy link
Owner Author

@interpeix Thanks a lot, I will create a new issue for this problem.

@gpstuff
Copy link

gpstuff commented Apr 12, 2022

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.

@sunny0826
Copy link
Owner Author

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.

@gpstuff thx for your feedback. I have created a new issue to track this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants