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

@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 180 lines in your changes missing coverage. Please review.

Project coverage is 59.30%. Comparing base (9861ce9) to head (c5cfb54).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5048      +/-   ##
==========================================
- Coverage   59.50%   59.30%   -0.20%     
==========================================
  Files         346      349       +3     
  Lines       29365    29665     +300     
==========================================
+ Hits        17474    17594     +120     
- Misses      10916    11086     +170     
- Partials      975      985      +10     

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
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