-
Notifications
You must be signed in to change notification settings - Fork 913
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
add shell completion code for fish #5876
Conversation
While working on the code modifications for this part, I encountered some difficulties and would like to seek your assistance. I noticed in the PR that when using Zsh and Bash as terminals, the completion functions can be loaded using the following method.
However, when testing with Fish and PowerShell scripts, I couldn't find a suitable way to achieve similar functionality. Currently, the scripts generated by
|
What is the specific error? |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5876 +/- ##
==========================================
+ Coverage 46.20% 47.37% +1.17%
==========================================
Files 663 663
Lines 54580 54763 +183
==========================================
+ Hits 25218 25945 +727
+ Misses 27739 27127 -612
- Partials 1623 1691 +68
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
When I use the commands However, when I use the command
All these issues happen even though saving the script outputted by the command into a file and then executing it directly in the terminal or using source xxx.fish enables the autocomplete functionality successfully. |
@tiansuo114 Thanks for your clear description. "Karmadactl completion bash" is used to generate the karmadactl completion script for Bash. The completion script depends on bash-completion, which means that you have to install this software first (you can test if you have bash-completion already installed by running type _init_completion). More info can refer to https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-bash-completion. But why would you test "Karmadactl completion bash"? If want to support PowerShell, the command to generate the script should be BTW, it is necessary to ensure the selection of the correct karmadactl binary for the test architecture. Given that our current release only provides builds for Linux and Darwin OS, it seems unnecessary for karmadactl to support PowerShell. WDYT? |
Yes, this was indeed a mistake on my part. During actual testing, I did use the command Regarding whether it is necessary to provide a completion method for PowerShell, I share your perspective. I also believe that for a tool currently designed only for Linux and Darwin OS, providing a PowerShell completion method is unnecessary and redundant. At this point, I think most of the issues have been resolved. The only remaining issue pertains to the fish terminal. It seems that the |
How about |
Thank you very much! This approach allows the completion scripts for the Fish terminal to load correctly. I will add the hints in the commands, remove the PowerShell-related code, and then push the changes. |
Glad to hear that! As for hints, I think we can take a page from # Load the kubectl completion code for fish[2] into the current shell
kubectl completion fish | source
# To load completions for each session, execute once:
kubectl completion fish > ~/.config/fish/completions/kubectl.fish |
1b029c4
to
2b97f95
Compare
Ok, I changed the relevant part, now how does the code look? |
/assign |
@tiansuo114 Some of the command descriptions need to be updated: karmada/pkg/karmadactl/completion/completion.go Lines 47 to 50 in 93a68eb
others LGTM. And it would be nice if you could provide local verification |
Okay, I will modify the related content as soon as possible. However, I have some questions regarding local validation. Can I understand it as adding something similar to what is pointed to in this link: #5533 (comment), or is it related to some other content? |
yes, just show some use case will be fine |
2b97f95
to
7b4ddea
Compare
This adds an example of code completion use cases for the fish shell, similar to the one in #5533. For the fish shell, you first need to temporarily load the completion script into the terminal using the following command:
Once the script is loaded into the terminal, the completion behavior will be identical to what is described in the linked documentation.Details are as follows:
Highlights
Using the
|
@tiansuo114 Good job~ just to confirm, are these commands executed in the fish shell? |
Yes, my testing environment is in an Ubuntu virtual machine on Windows, and I am using the fish shell for testing. |
/lgtm
It should be completion of %[1]s commands.
should be Long: fmt.Sprintf(completionLong, parentCommand),
|
7b4ddea
to
71f72fb
Compare
Ok, now these two errors have been modified😊 |
The shell code must be evaluated to provide interactive | ||
completion of kubectl commands. This can be done by sourcing it from | ||
completion of %[1]s commands This can be done by sourcing it from |
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.
completion of %[1]s commands This can be done by sourcing it from | |
completion of %[1]s commands. This can be done by sourcing it from |
The .
was accidentally deleted.
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.
Ok, the error here has been fixed
71f72fb
to
ba2a073
Compare
Signed-off-by: tiansuo114 <[email protected]> 11 Signed-off-by: tiansuo114 <[email protected]>
/lgtm |
Sure, but I have some questions. I'm not sure what the release notes should include. Could you provide an example? Also, where should I add the release notes? |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Add support for code completion capabilities for Fish and PowerShell terminals.
Which issue(s) this PR fixes:
Part of #5477
Special notes for your reviewer:
@zhzhuang-zju
Does this PR introduce a user-facing change?: