imgpkg
imgpkg copied to clipboard
Extra output and errors during shell completion
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.
Same issue in kapp
: https://github.com/vmware-tanzu/carvel-kapp/issues/583
What happened:
For bash, notice the error in this particular case (some other bash completions do work):
bash
bash-5.1$ source <(imgpkg completion bash)
bash-5.1$ imgpkg 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 <(imgpkg completion zsh)
$ compdef _imgpkg imgpkg
$ imgpkg <TAB>
completion -- Generate completion script
copy -- Copy a bundle from one location to another
describe -- Describe the images and bundles associated with a give bundle
help -- Help about any command
pull -- Pull files from bundle, image, or bundle lock file
push -- Push files as image
tag -- Tag (list, resolve)
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.
-
imgpkg
should not printSucceeded
for that command - output printed to
stderr
by the__complete
command should not be redirected byimgpkg
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:
- imgpkg version (use
imgpkg --version
): 0.30.0 - Docker registry used (e.g.
Docker HUB
): N/A - OS (e.g. from
/etc/os-release
): MacOS
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.
Hey, @marckhouzam thanks for creating the issue. We will sync up with kapp
folk and get this fix.
Also if you are interested in getting a PR with a fix for this we will be more than happy to look at it
Shipped as a part of v0.34.0.