-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
powershell completion with custom comp #1208
Conversation
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.
Thanks for doing this!
I haven't looked in detail but just a quick comment.
@marckhouzam I don't think I can get |
@Luap99 agreed. That's what I also had to do for fish completion: Lines 126 to 133 in 02a0d2f
|
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.
@Luap99 this works amazingly well!
I've pointed helm
to use your PR and it looks really great!
I've also done similar testing as I had done when working on the zsh v2 script, so it covers pretty much everything I think.
I just have some minor comments.
Great job!
# - TabCompleteNext (default windows style - on each key press the next option is displayed) | ||
# - Complete (works like bash) | ||
# - MenuComplete (works like zsh) | ||
# You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode> |
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.
Super nice! Each mode works great!
62508d9
to
d7aac2f
Compare
@marckhouzam Thanks for the fast review. I ignore |
@Luap99 Everything works great! As you said, the |
Oh, and I think you should remove |
I'm still thinking how this could be done. Powershell does not have
Not very nice but it could work. |
This is what
I think it is just fine. |
I'm curios does that work with file path completion? I got it working for powershell with arguments, but there is no way to make it work with file completion. |
d7aac2f
to
4af1e92
Compare
Ok, I think the script is in good shape now. I have added documentation, but it still needs to be refined. One question remains, how should the API look like? |
I hadn't realized, but no, it does not work with file completion. So, currently, for zsh (not using Cobra's zsh support):
I think that is fine. |
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.
Except for the API backwards-compatibility (which can be fixed easily), this looks ready and of great quality.
@jpmcb You may be interested in trying this out.
@jharshman In my opinion, it would be good to include this in the coming release. With this PR, Cobra provides full auto-completion for all 4 shells it supports.
I just tested this on windows 10 with the default powershell v5.1 and I noticed one problem. Apart from that, I think it works very well. |
I have no way of testing this on a windows machine. Are there other's in the community that would be able to lend a hand and test this out? |
I can confirm I see this same behavior with powershell 5.1. I think we'll just have to live with it. I've tested on Mac with
From a functionality perspective, not only do I feel this is complete, but I believe it is dramatically better than what we have right now for powershell. @jpmcb There is still a need for guidance on what form the API should take for programs to call this. |
d6075ef
to
ccb09b7
Compare
@marckhouzam Thanks for testing. I added one small thing to properly escape spacial chars with a backtick. So they can safely be used as input. I also changed the API to |
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.
Very nice.
Could you just add powershell
in shell_completions.md
in the Descriptions for completions
section?
The current powershell completion is not very capable. Let's port it to the go custom completion logic to have a unified experience accross all shells. Powershell supports three different completion modes - TabCompleteNext (default windows style - on each key press the next option is displayed) - Complete (works like bash) - MenuComplete (works like zsh) You set the mode with `Set-PSReadLineKeyHandler -Key Tab -Function <mode>` To keep it backwards compatible `GenPowerShellCompletion` will not display descriptions. Use `GenPowerShellCompletionWithDesc` instead. Descriptions will only be displayed with `MenuComplete` or `Complete`. Signed-off-by: Paul Holzinger <[email protected]>
ccb09b7
to
f2bf992
Compare
@jpmcb what do you think about merging this powershell completion patch? From my testing @Luap99 did a spectacular job with this. Furthermore, it seems no one can get the existing powershell completion to work at all currently, so there is no risk of breaking anything 😄 In fact, I checked-out the commit from the original powershell completion pr #797 and still only got flag completion to work; it seems the feature never properly worked. We need some good material for the next release and I thought this would be a great 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.
Thanks for the time and patience on this one - I'll go ahead and merge since there seems to be a consensus that this is indeed working on windows / powershell.
If anyone in the community is trying this out and finds issues, please feel free to open a new issue!!
The current powershell completion is not very capable.
Let's port it to the go custom completion logic to have a
unified experience accross all shells.
Powershell supports three different completion modes
You set the mode with
Set-PSReadLineKeyHandler -Key Tab -Function <mode>
Descriptions will only be supported for Complete and MenuComplete.
Fixes #1229