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

"Using config file" displays when doing completion command #56

Closed
christianh814 opened this issue Oct 20, 2022 · 3 comments
Closed

"Using config file" displays when doing completion command #56

christianh814 opened this issue Oct 20, 2022 · 3 comments

Comments

@christianh814
Copy link

Running

cobra-cli completion bash

Displays

Using config file: ~/.cobra.yaml

This isn't causing an issue, but it's a bit of a cosmetic annoyance, especially since I have source <(cobra-cli completion bash). This text displays every time I open a new terminal tab.

Is there a way to suppress it?

@marckhouzam
Copy link
Collaborator

marckhouzam commented Oct 20, 2022

Since this line is printed to stderr, the simplest thing to do is to redirect stderr:
source <(cobra-cli completion bash) 2> /dev/null.

The overall better approach is to avoid sourcing the completion script at every start of the shell. Instead you can store the completion script once in the shell's completion directory. You can run cobra-cli completion bash -h and follow the instructions.

@christianh814
Copy link
Author

Since this line is printed to stderr, the simplest thing to do is to redirect stderr: source <(cobra-cli completion bash) 2> /dev/null.

This doesn't work

$ source <(cobra-cli completion bash) 2> /dev/null
Using config file: /home/chernand/.cobra.yaml

The overall better approach is to avoid sourcing the completion script at every start of the shell. Instead you can store the completion script once in the shell's completion directory. You can run cobra-cli completion bash -h and follow the instructions.

My preference isn't to load these into a file but instead, load it dynamically. Reason for this is that I don't have to update the completion every time the CLI changes.

@marckhouzam
Copy link
Collaborator

Since this line is printed to stderr, the simplest thing to do is to redirect stderr: source <(cobra-cli completion bash) 2> /dev/null.

This doesn't work

Sorry, my mistake. You should use source <(cobra-cli completion bash 2> /dev/null)

My preference isn't to load these into a file but instead, load it dynamically. Reason for this is that I don't have to update the completion every time the CLI changes.

Valid point. For CLIs that are installed with a package manager, this should all be taken care of automatically. But if not, then I understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants