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

🚧 feat: autocompletion installer 🚧 #5048

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Benehiko
Copy link
Member

@Benehiko Benehiko commented Apr 30, 2024

- What I did
Override the cobra completion command to add extra functionality such as automatically installing completions on the user machine. The behavior of the completion command should still generate cobra commands.

- How I did it
Added a completion cobra.Command onto the root command.

- How to verify it
Run docker completion --help

Some examples:

docker completion zsh --manual
mkdir -p .docker/completions && docker completion zsh > .docker/completions/_docker
cat <<EOT >> .zshrc
# The following lines have been added by Docker to enable Docker CLI completions.
fpath=(.docker/completions/_docker $fpath)
autoload -Uz compinit
compinit
EOT
# End of Docker Completions⏎ 

Running the auto installer

> ~/G/d/c/docker on completion-installer ⨯ go run . completion install

Detected shell [fish]

The automatic installer will do the following:

	mkdir -p /home/benehiko/.config/fish/completions
	docker completion fish > /home/benehiko/.config/fish/completions/docker.fish

Are you sure you want to continue? [y/N]

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

image

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 39.64758% with 137 lines in your changes missing coverage. Please review.

Project coverage is 61.34%. Comparing base (7f15dfa) to head (a123a86).
Report is 280 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5048      +/-   ##
==========================================
+ Coverage   61.08%   61.34%   +0.25%     
==========================================
  Files         295      298       +3     
  Lines       20660    21040     +380     
==========================================
+ Hits        12621    12907     +286     
- Misses       7142     7204      +62     
- Partials      897      929      +32     

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

Successfully merging this pull request may close these issues.

3 participants