-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[completion/zsh] add volume completion #2998
Conversation
This provides completion for `docker run ... -v <TAB>`. This closes (part of) docker#1997. Signed-off-by: Paul Seyfert <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #2998 +/- ##
=======================================
Coverage 57.06% 57.06%
=======================================
Files 299 299
Lines 18683 18683
=======================================
Hits 10662 10662
Misses 7155 7155
Partials 866 866 |
Any maintainer out there willing to review / approve? ( @thaJeztah , tagging you as you appear in the other completion related MRs) |
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.
Looks good to me.
However, I think that in the long run we would like to get rid of the manually maintained completions scripts and continue with the approach started by @ndeloof with #3429 (using Cobra's completion generation feature).
So probably it would be good to take a look how to implement this completion with the Cobra.
@vvoland thanks for the feedback. I appreciate the effort going for a generated completion feature rather than the manually maintained function. That said, shall we still try to merge the MR here? It improves the completion file while it's still there. And admittedly I don't (yet?) find my way around the cobra completion, so it will take a bit until I can contribute to that. |
The only thing I was wondering is if it should complete (named) volumes, and if so, how we could make it either complete those, or local paths (for bind-mounts). Not exactly sure what we currently do for the Bash completion (maybe we don't do it there either) |
(close/reopen to trigger CI) |
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.
LGTM
This provides completion for
docker run ... -v <TAB>
.This closes part of #1997.
docker run -it
is discussed in the issue and does not require a fix (maybe a different default, but that's out of scope here)docker run ... -v
is addressed in this PRAs outlined here there are multiple options passed to
_directories
. The behaviour is that:docker run -v <TAB>
inserts a/
immediately and will suggest directories relative to/
. On my system that meansdocker run -v <TAB>
turns intodocker run -v /
and the completion list contains elements such asusr
,home
:
is inserted at the end of every suggestion. depending how the user configured their completion this means they can cycle through insertions ofdocker run -v /usr:
docker run -v /home:
and so on (for me the colon is bold face).:
does not need to be removed by the user if they want to go one level higher. hitting space or/
will remove the:
. I.e. hitting/
after the completion inserteddocker run -v /usr:
turns the command line intodocker run -v /usr/
. Continued hitting of TAB continues the game and suggestsdocker run -v /usr/bin:
, again with a self-removing:
:
persists if the user types:
:
in the same word there is no more completion suggestions, the user needs to type the volume mount on their own.docker run -v /home
ordocker run -v /home:/hosthome
) the completion continues to complete arguments to docker run just like it did before this PR.Verification was trying around on the command line with
docker run -it --rm -v <stuff here> debian:testing
. I think the suggestions should be absolute paths (the original draft suggested relative paths to the cwd, but docker didn't mount them).One can probably argue if the treatment of the trailing
:
is optimal (self removal on space and slash. i caught myself a few times that after havingdocker run -it --rm -v /home:
i tried to continue with/hosthome
and wanting to type-v /home:/hosthome
but typed/home/hosthome
as the/
overwrote the visual:
).not an animal, but a cake: