-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Print ActiveHelp for bash along other completions #2076
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
Merged
marckhouzam
merged 1 commit into
spf13:main
from
marckhouzam:feat/improveBashActiveHelp
Jan 30, 2025
Merged
Print ActiveHelp for bash along other completions #2076
marckhouzam
merged 1 commit into
spf13:main
from
marckhouzam:feat/improveBashActiveHelp
Jan 30, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the bash shell we used to print ActiveHelp messages on every tab-press. In the example below, notice the "Command help" line which is ActiveHelp: bash-5.1$ tanzu context u[tab] Command help: Configure and manage contexts for the Tanzu CLI bash-5.1$ tanzu context u[tab] Command help: Configure and manage contexts for the Tanzu CLI bash-5.1$ tanzu context u unset (Unset the active context so that it is not used by default.) use (Set the context to be used by default) bash-5.1$ tanzu context u Above, on the first [tab] press, only the ActiveHelp is printed. On the second [tab] press, the ActiveHelp is printed again, followed by a re-print of the command-line, followed by the completions choices. The separation between ActiveHelp and completion choices makes the ActiveHelp harder to see. Furthermore, I find the double printing of the ActiveHelp string to look bad. Note that for zsh, the UX is different and that ActiveHelp messages are printed at the same time as the completion choices. This commit aligns the UX for ActiveHelp in bash with the one for zsh: if there are other completions to be shown, the ActiveHelp messages are printed at the same time. New behaviour: 1- ActiveHelp is no longer printed on the first [tab] press. This is better aligned with bash's standard approach. 2- ActiveHelp is printed on the second [tab] press, above the completion choices, with a `--` delimiter. 3- If there are no completion choices, the `--` delimiter is omitted. This behaviour is the same as what is done for zsh (except that for zsh the first [tab] press immediately shows completion choices). Below is the above example, but using this commit. Notice the more concise and easier to read completion output: bash-5.1$ tanzu context u[tab][tab] Command help: Configure and manage contexts for the Tanzu CLI -- unset (Unset the active context so that it is not used by default.) use (Set the context to be used by default) bash-5.1$ tanzu context u Signed-off-by: Marc Khouzam <[email protected]>
15823e7
to
e9e9e2a
Compare
jpmcb
approved these changes
Jan 30, 2025
Crown0815
pushed a commit
to Crown0815/forgejo-runner-windows
that referenced
this pull request
May 21, 2025
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/spf13/cobra](https://github.com/spf13/cobra) | require | minor | `v1.8.1` -> `v1.9.1` | --- ### Release Notes <details> <summary>spf13/cobra (github.com/spf13/cobra)</summary> ### [`v1.9.1`](https://github.com/spf13/cobra/releases/tag/v1.9.1) [Compare Source](spf13/cobra@v1.9.0...v1.9.1) ##### 🐛 Fixes - Fix CompletionFunc implementation by [@​ccoVeille](https://github.com/ccoVeille) in spf13/cobra#2234 - Revert "Make detection for test-binary more universal ([#​2173](spf13/cobra#2173))" by [@​marckhouzam](https://github.com/marckhouzam) in spf13/cobra#2235 **Full Changelog**: spf13/cobra@v1.9.0...v1.9.1 ### [`v1.9.0`](https://github.com/spf13/cobra/releases/tag/v1.9.0) [Compare Source](spf13/cobra@v1.8.1...v1.9.0) #### ✨ Features - Allow linker to perform deadcode elimination for program using Cobra by [@​aarzilli](https://github.com/aarzilli) in spf13/cobra#1956 - Add default completion command even if there are no other sub-commands by [@​marckhouzam](https://github.com/marckhouzam) in spf13/cobra#1559 - Add CompletionWithDesc helper by [@​ccoVeille](https://github.com/ccoVeille) in spf13/cobra#2231 #### 🐛 Fixes - Fix deprecation comment for Command.SetOutput by [@​thaJeztah](https://github.com/thaJeztah) in spf13/cobra#2172 - Replace deprecated ioutil usage by [@​nirs](https://github.com/nirs) in spf13/cobra#2181 - Fix --version help and output for plugins by [@​nirs](https://github.com/nirs) in spf13/cobra#2180 - Allow to reset the templates to the default by [@​marckhouzam](https://github.com/marckhouzam) in spf13/cobra#2229 #### 🤖 Completions - Make Powershell completion work in constrained mode by [@​lstemplinger](https://github.com/lstemplinger) in spf13/cobra#2196 - Improve detection for flags that accept multiple values by [@​thaJeztah](https://github.com/thaJeztah) in spf13/cobra#2210 - add CompletionFunc type to help with completions by [@​ccoVeille](https://github.com/ccoVeille) in spf13/cobra#2220 - Add similar whitespace escape logic to bash v2 completions than in other completions by [@​kangasta](https://github.com/kangasta) in spf13/cobra#1743 - Print ActiveHelp for bash along other completions by [@​marckhouzam](https://github.com/marckhouzam) in spf13/cobra#2076 - fix(completions): Complete map flags multiple times by [@​gabe565](https://github.com/gabe565) in spf13/cobra#2174 - fix(bash): nounset unbound file filter variable on empty extension by [@​scop](https://github.com/scop) in spf13/cobra#2228 #### 🧪 Testing - Test also with go 1.23 by [@​nirs](https://github.com/nirs) in spf13/cobra#2182 - Make detection for test-binary more universal by [@​thaJeztah](https://github.com/thaJeztah) in spf13/cobra#2173 #### ✍🏼 Documentation - docs: update README.md by [@​eltociear](https://github.com/eltociear) in spf13/cobra#2197 - Improve site formatting by [@​nirs](https://github.com/nirs) in spf13/cobra#2183 - doc: add Conduit by [@​raulb](https://github.com/raulb) in spf13/cobra#2230 - doc: azion project added to the list of CLIs that use cobra by [@​maxwelbm](https://github.com/maxwelbm) in spf13/cobra#2198 - Fix broken links in active_help.md by [@​vuil](https://github.com/vuil) in spf13/cobra#2202 - chore: fix function name in comment by [@​zhuhaicity](https://github.com/zhuhaicity) in spf13/cobra#2216 #### 🔧 Dependency upgrades - build(deps): bump github.com/cpuguy83/go-md2man/v2 from 2.0.5 to 2.0.6 by [@​thaJeztah](https://github.com/thaJeztah) in spf13/cobra#2206 - Update to latest go-md2man by [@​mikelolasagasti](https://github.com/mikelolasagasti) in spf13/cobra#2201 - Upgrade `pflag` dependencies for v1.9.0 by [@​jpmcb](https://github.com/jpmcb) in spf13/cobra#2233 *** Thank you to all of our amazing contributors and all the great work that's been going into the completions feature!! ##### 👋🏼 New Contributors - [@​gabe565](https://github.com/gabe565) made their first contribution in spf13/cobra#2174 - [@​maxwelbm](https://github.com/maxwelbm) made their first contribution in spf13/cobra#2198 - [@​lstemplinger](https://github.com/lstemplinger) made their first contribution in spf13/cobra#2196 - [@​vuil](https://github.com/vuil) made their first contribution in spf13/cobra#2202 - [@​mikelolasagasti](https://github.com/mikelolasagasti) made their first contribution in spf13/cobra#2201 - [@​zhuhaicity](https://github.com/zhuhaicity) made their first contribution in spf13/cobra#2216 - [@​ccoVeille](https://github.com/ccoVeille) made their first contribution in spf13/cobra#2220 - [@​kangasta](https://github.com/kangasta) made their first contribution in spf13/cobra#1743 - [@​aarzilli](https://github.com/aarzilli) made their first contribution in spf13/cobra#1956 **Full Changelog**: spf13/cobra@v1.8.1...v1.9.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4wLjgiLCJ1cGRhdGVkSW5WZXIiOiI0MC4wLjgiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/557 Reviewed-by: earl-warren <[email protected]> Co-authored-by: Renovate Bot <[email protected]> Co-committed-by: Renovate Bot <[email protected]>
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/shell-completion
All shell completions
kind/feature
A feature request for cobra; new or enhanced behavior
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the bash shell we used to print ActiveHelp messages on every tab-press. In the example below, notice the
Command help
line which is ActiveHelp:Above, on the first [tab] press, only the ActiveHelp is printed. On the second [tab] press, the ActiveHelp is printed again, followed by a re-print of the command-line, followed by the completions choices.
The separation between ActiveHelp and completion choices makes the ActiveHelp harder to see. Furthermore, I find the double printing of the ActiveHelp string to look bad.
Note that for zsh, the UX is different and that ActiveHelp messages are printed at the same time as the completion choices.
This commit aligns the UX for ActiveHelp in bash with the one for zsh: if there are other completions to be shown, the ActiveHelp messages are printed at the same time.
New behaviour:
1- ActiveHelp is no longer printed on the first [tab] press. This is
better aligned with bash's standard approach.
2- ActiveHelp is printed on the second [tab] press, above the completion
choices, with a
--
delimiter.3- If there are no completion choices, the
--
delimiter is omitted.This behaviour is the same as what is done for zsh (except that for zsh the first [tab] press immediately shows completion choices).
Below is the above example, but using this commit.
Notice the more concise and easier to read completion output: