-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Fix zsh autocomplete #3221
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
Fix zsh autocomplete #3221
Conversation
efe965b to
e80d71a
Compare
e80d71a to
6d5a731
Compare
6d5a731 to
6d9dec3
Compare
|
cc @sdurrheimer |
56c0e6f to
2075944
Compare
2075944 to
1bce90f
Compare
1bce90f to
7e80ab4
Compare
|
@sdurrheimer rebased! |
| | sed -n -e '/^services:/,/^[^ ]/p' \ | ||
| | sed -n 's/^ //p' \ | ||
| | awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \ | ||
| | awk -F: -v key=": +$1:" '$0 ~ key {print $1}' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you squash that changed with @cbfe6d0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @albers This might interest you given that we are using the same services parsing method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sdurrheimer Yes, that's identical with my version.
It improves readibility at the cost of one extra command invocation. I think that's OK.
I have two suggestions, though which i'll add below.
@aeriksson would you mind to adjust this function in the bash completion as well so that both completions stay aligned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albers sure, I'll create a bash PR too
15c1c4f to
2211d2f
Compare
|
LGTM |
| docker-compose 2>/dev/null $compose_options "$@" | ||
| } | ||
|
|
||
| # Extracts all service names from docker-compose.yml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albers what should the comment say?
I removed it to be in line with the bash script:
https://github.com/docker/compose/blob/master/contrib/completion/bash/docker-compose#L20-L22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with removing the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeriksson Can you do that change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sdurrheimer not sure what the change is…
Maybe I misunderstood something, but I think @albers asked me to update that comment rather than removing it.
I then pointed out that I removed it because it was no longer needed, and there is no corresponding comment on the same function in the bash script.
I take what @albers wrote after to mean that after some deliberation, he was okay with the comment being removed.
Again, I might be wrong here, and I'd gladly add a comment if there's a need for one :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeriksson The comment refers to the previous way of harvesting the service names from docker-compose.yml. The comment pointed out that the service list had some limitations: it did not take into account several other configuration files that were added over time.
Now, we use an official API for that task: docker-compose config. We let docker-compose combine all the configuration sources. But the comment was not updated and now is wrong.
There are two ways to resolve this mismatch:
- change the comment to "Extracts all service names from the output of docker-compose config"
- drop the comment
I favour solution 2 because the comment from solution 1 is trivial. The new code does not need a comment any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and solution 2 is what is implemented in this PR, so no further changes should be required, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeriksson: @albers is talking about the comment line 26/36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Updated that comment to say "All services defined in docker-compose.yml" rather than "Extracts all service names from docker-compose.yml".
|
Hello, what is the state of this PR ? |
|
AFAICT it's ready to merge. |
This has the added benefit of making autocompletion work when the docker-compose config file is in a parent directory. Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
For autocomplete to work properly, we need to pass along some flags when calling docker (--host, --tls, …) and docker-compose (--file, --tls, …). Previously flags would only be passed to docker-compose, and the only flags passed were --file and --project-name. This commit makes sure that all relevant flags are passed to both docker-compose and docker. Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Previously, the autocomplete for the build/pull commands would only add services for which build/image were the _first_ keys, respectively, in the docker-compose file. This commit fixes this, so the appropriate services are listed regardless of the order in which they appear Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Previously, the filtering on already selected services would break when one service was a substring of another. This commit fixes that. Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
Signed-off-by: Andre Eriksson <aepubemail@gmail.com>
2211d2f to
c3247e7
Compare
|
Ok LGTM |
|
LGTM |
|
LGTM, thanks! |
Fix zsh autocomplete (cherry picked from commit c0237a4) Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This fixes a few issues with the zsh autocomplete script, and brings it up to date with the current docker-compose commands.
Changes:
docker-compose configinstead of manually trying to find and parse the docker-compose file. This fixes a few issues:docker-compose help xproduces (fixed some typos and outdated/incorrect help texts).docker-composeanddocker, so autocomplete works even if--tls,--tlskey, etc are set.build,pullwould only show some services.