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

Fix invalid shell completion when used with ~/.cobra.yaml #1510

Merged
merged 1 commit into from Dec 7, 2021

Conversation

darklore
Copy link
Contributor

@darklore darklore commented Oct 21, 2021

cobra completion outputs invalid output "Using config file:" at the top of the completion script. when ~/.cobra.yaml exists.

`cobra completion` outputs invalid output "Using config file:" at the
top of the completion script. when ~/.cobra.yaml exists.
@CLAassistant
Copy link

CLAassistant commented Oct 21, 2021

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the area/cli [deprecated] For the cobra CLI !!! moved to spf13/cobra-cli label Oct 21, 2021
@marckhouzam
Copy link
Collaborator

marckhouzam commented Oct 21, 2021

@darklore thanks for the PR.
Could you describe the steps to reproduce the problem so we can better understand?
Also, a test would be nice to avoid this breaking again.

@darklore
Copy link
Contributor Author

darklore commented Oct 21, 2021

Sorry.

Reproduce steps

  1. Place valid cobra.yaml to ~/.cobra.yaml
  2. Execute cobra completion zsh > /usr/local/share/zsh/site-functions/_cobra

Problem

  • zsh completion for cobra command doesn't work.
  • /usr/local/share/zsh/site-functions/_cobra have invalid line such as Using config file: ~/.cobra.yaml` at the beginning of the file.

Copy link
Collaborator

@marckhouzam marckhouzam left a comment

I can reproduce this.
When there's a cobra configuration file, the Cobra cli always prints "Using config file:..." to stdout, which ends up in the shell completion scripts of the Cobra cli.

Sending that output to stderr as done by this PR seems like a reasonable solution. I don't think backwards-compatibility is a big concern in this case.

Thanks @darklore !

umarcor pushed a commit to umarcor/cobra that referenced this pull request Nov 5, 2021
`cobra completion` outputs invalid output "Using config file:" at the
top of the completion script. when ~/.cobra.yaml exists.
umarcor pushed a commit to umarcor/cobra that referenced this pull request Nov 15, 2021
`cobra completion` outputs invalid output "Using config file:" at the
top of the completion script. when ~/.cobra.yaml exists.
umarcor pushed a commit to umarcor/cobra that referenced this pull request Nov 16, 2021
`cobra completion` outputs invalid output "Using config file:" at the
top of the completion script. when ~/.cobra.yaml exists.
umarcor pushed a commit to umarcor/cobra that referenced this pull request Nov 25, 2021
`cobra completion` outputs invalid output "Using config file:" at the
top of the completion script. when ~/.cobra.yaml exists.
jpmcb
jpmcb approved these changes Dec 7, 2021
Copy link
Collaborator

@jpmcb jpmcb left a comment

Good catch! 👍

@jpmcb jpmcb merged commit 25bab5a into spf13:master Dec 7, 2021
2 checks passed
@jpmcb jpmcb added this to the 1.3.0 milestone Dec 7, 2021
umarcor pushed a commit to umarcor/cobra that referenced this pull request Dec 7, 2021
`cobra completion` outputs invalid output "Using config file:" at the
top of the completion script. when ~/.cobra.yaml exists.
@darklore darklore deleted the fix-invalid-shell-completion branch Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli [deprecated] For the cobra CLI !!! moved to spf13/cobra-cli
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants