compose icon indicating copy to clipboard operation
compose copied to clipboard

Add completion command and fix convert

Open ulyssessouza opened this issue 3 years ago • 2 comments
trafficstars

What I did Add completion command and fix convert

To test, you can trigger the completions with the following example:

  1. Create a compose file with the following content: compose.yaml
services:
  foo:
    image: nginx
  bar:
    image: nginx
  baz:
    image: nginx
  1. Then run the following command:
$ docker compose __complete up ""

This should print the 3 services as proposals

  1. By running
$ docker compose __complete up "b"

This should propose the 2 services starting with the letter "b"

For now, the Docker CLI is not triggering compose's completion yet. That should be done in a following PR.

ulyssessouza avatar Mar 11 '22 04:03 ulyssessouza

Ah project name completion isn't working, it looks like the backend instance isn't initialized?

I'm getting not implemented error and all the funcs on the ServiceProxy are nil at the point that completeProjectNames is called 😭

milas avatar Sep 21 '22 14:09 milas

Oh, we lazily initialize the ServiceProxy via PersistentPreRunE which presumably does NOT run for the auto-completion 😬

https://github.com/docker/compose/blob/db882416985a2d36ee82f869920ad9ce9d4c2caa/cmd/main.go#L41-L44

milas avatar Sep 21 '22 14:09 milas

@milas Good catch! I changed to populate the serviceProxy on creation... We could actually get rid of this, but that can be useful on state tracing with interceptors.

ulyssessouza avatar Sep 23 '22 18:09 ulyssessouza

Should this close #8550 as well?

nicksieger avatar Sep 27 '22 19:09 nicksieger