docker / cli

The Docker CLI
Apache License 2.0
4.77k stars 1.89k forks source link

🚧 feat: autocompletion installer 🚧 #5048

Open Benehiko opened 2 months ago

Benehiko commented 2 months ago

- 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 commented 1 month ago

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 ```diff @@ 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 ```