vladimir-kotikov / clink-completions

Completion files to clink util
MIT License
379 stars 81 forks source link

Add completion for 'docker' #40

Open viskin opened 8 years ago

viskin commented 8 years ago

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

vladimir-kotikov commented 8 years ago

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

vladimir-kotikov commented 8 years ago

Also, bash completions will be helpful, thanks.

orestesgaolin commented 6 years ago

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

cc: @viskin

jkoenig134 commented 4 years ago

@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.

vladimir-kotikov commented 4 years ago

@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

jkoenig134 commented 4 years ago

Ok, thank you. I will look at it.

chrisant996 commented 2 years ago

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.

jocafi commented 1 year ago

I am waiting for this feature 👍

chrisant996 commented 1 year ago

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.

jocafi commented 1 year ago

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\

6) The containers or files section are only showed if they exist, otherwise the section shall be hidden. 7) The list in memory can only be updated after 20s has elapsed (after step 2) and the user presses TAB again 8) 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. 9) 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. 10) 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 !

chrisant996 commented 1 year ago

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).

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