clink-completions icon indicating copy to clipboard operation
clink-completions copied to clipboard

Add completion for 'docker'

Open viskin opened this issue 8 years ago • 11 comments

Docker client is popular tool that now available on Windows: https://docs.docker.com/windows/step_one/ It comes with bash completion file: https://github.com/docker/docker/blob/master/contrib/completion/bash/docker

viskin avatar Dec 07 '15 07:12 viskin

@viskin, accepted. However, i'm not a user of Docker, so please don't expect this will be done soon, sorry.

vladimir-kotikov avatar Dec 07 '15 12:12 vladimir-kotikov

Also, bash completions will be helpful, thanks.

vladimir-kotikov avatar Dec 07 '15 12:12 vladimir-kotikov

For those who are looking for Docker completion in Windows here is the list of currently available solutions:

  • https://github.com/matt9ucci/DockerCompletion - quite recent commits present in repository, install with Install-Module DockerCompletion
  • https://github.com/samneirinck/posh-docker - I use this one - after installation with Install-Module Posh-Docker (administrative rights required) you can just add Import-Module Posh-Docker to vendor/profile.ps1 in cmder directory

cc: @viskin

orestesgaolin avatar Jan 15 '18 07:01 orestesgaolin

@vladimir-kotikov do you plan to add the docker-completion? The new bash-completion file for docker is located here. A command completion for docker-compose would also be awesome. The completion for that is located here.

jkoenig134 avatar Jan 15 '20 13:01 jkoenig134

@jkoenig134 I don't as I'm not actively working on this project. There's a PR with basic completions here: https://github.com/vladimir-kotikov/clink-completions/pull/73 which you can grab and put along with other lua files in your cmder installation and get these completions working - I'd love to merge that PR but have some concerns about the implementation so still haven't decided about it

vladimir-kotikov avatar Jan 15 '20 18:01 vladimir-kotikov

Ok, thank you. I will look at it.

jkoenig134 avatar Jan 16 '20 07:01 jkoenig134

I see the implementation concerns Vladimir had, and I also see why the implementation was done that way, given limitations in Clink v0.4.9.

But newer versions of Clink natively support delayed initialization of argmatchers, so this is very doable now.

I'll look at getting docker completions included.

chrisant996 avatar Aug 15 '22 07:08 chrisant996

I am waiting for this feature 👍

jocafi avatar Aug 27 '23 22:08 jocafi

I know nothing about docker and have never used it. That makes it extremely difficult for me to personally be the one to hook up completions for docker as I have absolutely no way to test them.

chrisant996 avatar Aug 28 '23 00:08 chrisant996

Hi @chrisant996, the docker autocomplete feature exists for other terminals.

I know that if I press TAB in the cmder console after typing the letters do, the following results are shown in my case:

docker.exe docker-compose-v1.exe docker-credential-ecr-login.exe docker-index.exe doskey.exe docker-compose.exe docker-credential-desktop.exe docker-credential-wincred.exe dos2unix.exe

If I start any command on cmder, for example "cat " with space at the end and press TAB, cmder shows the files or directories of the actual path.

I wrote down some requirements to develop and test this feature. For sure you need to install docker on your machine and pull some small containers in order to test the feature. I can help you in this matter, if you want.

Requirements:

  1. The user writes the word docker (docker.exe) or docker-compose (or docker-compose.exe) on cmder and presses SPACE
  2. The user presses TAB after the previous step
  3. Cmder in this case executes the command "docker ps" in background (hidden from console)
  4. Cmder parses the result and extract the docker container names (if they exist) and store them in the memory as a list
  5. cmder shows the list of files / directories and the list of containers on the console (same feature as showing the files in the console in the actual version) separated by a header. Example:

Containers: my-postgres my-mongo-db my-node-web-server

Files or directories: .dockerignore app.js Dockerfile package.json config\

  1. The containers or files section are only showed if they exist, otherwise the section shall be hidden.
  2. The list in memory can only be updated after 20s has elapsed (after step 2) and the user presses TAB again
  3. If the user starts typing a word and presses TAB, cmder checks if the typed letters matches the start string of a file/dir or container in the memory list.
  4. If the pressed letter(s) match(es) only one word, cmder completes the word automatically. This is the actual behaviour, but it works only for files / dir.
  5. If the word matches two or more words, cmder shows the list in the console as explained in the step 5.

If you have questions, feel free to contact me. Thank you !

jocafi avatar Aug 28 '23 11:08 jocafi

I know that if I press TAB in the cmder console after typing the letters do, the following results are shown in my case:

docker.exe docker-compose-v1.exe docker-credential-ecr-login.exe docker-index.exe doskey.exe docker-compose.exe docker-credential-desktop.exe docker-credential-wincred.exe dos2unix.exe

That's because you have docker installed. Those are not docker completions, those are filename completions. Docker completions wouldn't start until after you type the program name.

If I start any command on cmder, for example "cat " with space at the end and press TAB, cmder shows the files or directories of the actual path.

Are you trying to help me understand what completions are and how they work? I'm the maintainer of the Clink program, and I'm familiar with how completions work in general and in Clink. What you described is basic filename completion that happens when there is no argmatcher completion script for a program.

I wrote down some requirements to develop and test this feature. For sure you need to install docker on your machine and pull some small containers in order to test the feature. I can help you in this matter, if you want.

I'm not volunteering to write docker completions. I'm not volunteering to install docker and learn docker. That would be a large investment of my time, for something I don't use (and won't have any reason to use any time in the foreseeable future).

If docker completions are to be written, someone who uses docker should do so. I can help with specific questions about how to do various things in Lua when writing completion scripts for Clink. The place to start is the Clink documentation, and especially the section Argument Completion.

Requirements:

  1. The user writes the word docker (docker.exe) or docker-compose (or docker-compose.exe) on cmder and presses SPACE
  2. The user presses TAB after the previous step
  3. Cmder in this case executes the command "docker ps" in background (hidden from console)
  4. Cmder parses the result and extract the docker container names (if they exist) and store them in the memory as a list
  5. cmder shows the list of files / directories and the list of containers on the console (same feature as showing the files in the console in the actual version) separated by a header. Example:

Containers: my-postgres my-mongo-db my-node-web-server

Files or directories: .dockerignore app.js Dockerfile package.json config\

  1. The containers or files section are only showed if they exist, otherwise the section shall be hidden.
  2. The list in memory can only be updated after 20s has elapsed (after step 2) and the user presses TAB again
  3. If the user starts typing a word and presses TAB, cmder checks if the typed letters matches the start string of a file/dir or container in the memory list.
  4. If the pressed letter(s) match(es) only one word, cmder completes the word automatically. This is the actual behaviour, but it works only for files / dir.
  5. If the word matches two or more words, cmder shows the list in the console as explained in the step 5.

If you have questions, feel free to contact me. Thank you !

Replace "cmder" with "a docker completion script written for clink": Cmder or ConEmu aren't involved in any of the above.

The requirements list above can be reduced to a single requirement (everything else is just basics of how completions work in general).

  • Completions after "docker" should list containers and files.

But docker also has commands and flags, and there should be completions for those, as well.

chrisant996 avatar Aug 28 '23 20:08 chrisant996