Extra output and errors during shell completion
marckhouzam opened this issue · comments
What steps did you take:
There is extra output in the shell completion choices and in some cases is even causes errors during shell completion.
What happened:
For bash, notice the error in this particular case (some other bash completions do work):
bash
bash-5.1$ source <(kapp completion bash)
bash-5.1$ kapp help <TAB>
bash: ShellCompDirectiveNoFileComp
Succeeded: syntax error in expression (error token is "Succeeded")
For zsh, notice the extra output at the end (:4
, Succeeded
, etc):
$ source <(kapp completion zsh)
$ compdef _kapp kapp
$ kapp <TAB>
app-change -- App change (garbage-collect, list)
app-group -- app-group will deploy/delete an application for each subdirectory within a
completion -- Output shell completion code for the specified shell (bash, zsh or fish)
config-map -- Config map (list)
delete -- Delete app
deploy -- Deploy app
deploy-config -- Show default deploy config
help -- Help about any command
inspect -- Inspect app
label -- Print specified app label
list -- List all apps in a namespace
logs -- Print app's Pod logs
rename -- Rename app
service-account -- Service account (list)
tools -- Tools (diff, inspect, list-labels)
version -- Print client version
:4 Succeeded
Completion ended with directive: ShellCompDirectiveNoFileComp
Also happens for fish shell.
What did you expect:
Shell completion to work as expected, without error or extra output.
Anything else you would like to add:
Shell completion uses the hidden __complete
command provided by the Cobra project to obtain the shell completion choices.
kapp
should not printSucceeded
for that command- output printed to
stderr
by the__complete
command should not be redirected bykapp
tostdout
(that is the problem for the string outputCompletion ended with directive: ShellCompDirectiveNoFileComp
)
This command is added by Cobra when rootCmd.Execute()
is called, which makes it a little trickier to adjust the behaviour for it.
Environment:
- kapp version (use
kapp --version
): 0.52.0 - OS (e.g. from
/etc/os-release
): MacOS - Kubernetes version (use
kubectl version
): N/A
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
Thanks for reporting this @marckhouzam. Checking it out.
BTW, some projects explicitly check if processing with the __complete
command and adapt their behaviour accordingly.
@marckhouzam which version of kapp are you using? i believe latest of kapp should not have this problem.
@marckhouzam which version of kapp are you using? i believe latest of kapp should not have this problem.
Version 0.52.0
as installed by brew
.
I just tried on the develop
branch and I see the problem.
Note that this similar but not the same problem as #447. The completion
command had a similar problem and now we need to fix the __complete
command.
output printed to stderr by the __complete command should not be redirected by kapp to stdout (that is the problem for the string output Completion ended with directive: ShellCompDirectiveNoFileComp)
💯
Released as part of v0.53.0