Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Add support for completions in fish and powershell #3550

Merged
merged 1 commit into from Oct 25, 2022

Conversation

marckhouzam
Copy link
Contributor

What this PR does / why we need it

This PR allows tanzu users to use shell completion for fish or powershell.
This is directly supported by Cobra and all this PR does is give access to the scripts.

Which issue(s) this PR fixes

Fixes #3158

Describe testing done for PR

Powershell:

$ pwsh
PS /Users/kmarc/git/tanzu-framework> ./tanzu <TAB>
# File completion is triggered.  This is not correct.

# Source the new completion script for powershell
PS /Users/kmarc/git/tanzu-framework> ./tanzu completion powershell | Out-String | Invoke-Expression
PS /Users/kmarc/git/tanzu-framework> ./tanzu <TAB>
completion  (Output shell completion code)                     init        (Initialize the CLI)
config      (Configuration for the CLI)                        plugin      (Manage CLI plugins)
context     (Configure and manage contexts for the Tanzu CLI)  update      (Update the CLI)
help        (Help about any command)                           version     (Version information)

Fish

$ fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
kmarc@kmarc-a01 ~/g/tanzu-framework (feat/compFish)> ./tanzu <TAB>
# File completion is triggered.  This is not correct.

# Source the new completion script for fish
kmarc@kmarc-a01 ~/g/tanzu-framework (feat/compFish)> ./tanzu completion fish | source
kmarc@kmarc-a01 ~/g/tanzu-framework (feat/compFish)> ./tanzu <TAB>
completion                  (Output shell completion code)  help  (Help about any command)  update        (Update the CLI)
config                         (Configuration for the CLI)  init      (Initialize the CLI)  version  (Version information)
context  (Configure and manage contexts for the Tanzu CLI)  plugin    (Manage CLI plugins)

Release note

The Tanzu CLI now supports shell completion for the fish shell and powershell.

Additional information

You can install powershell on Mac.

Special notes for your reviewer

Note also that with Cobra 1.5, it is no longer necessary to have zsh >= 5.2 (see spf13/cobra#1665).
So I have update the help text.

@marckhouzam marckhouzam requested a review from a team as a code owner October 4, 2022 21:00
@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Merging #3550 (53e538a) into main (a6760d3) will decrease coverage by 0.90%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3550      +/-   ##
==========================================
- Coverage   46.55%   45.65%   -0.91%     
==========================================
  Files         400      425      +25     
  Lines       39706    41266    +1560     
==========================================
+ Hits        18486    18839     +353     
- Misses      19528    20716    +1188     
- Partials     1692     1711      +19     
Impacted Files Coverage Δ
cli/core/pkg/command/completion.go 85.00% <100.00%> (+3.75%) ⬆️
packageclients/pkg/packageclient/package_update.go 83.57% <0.00%> (-1.43%) ⬇️
...ons/controllers/packageinstallstatus_controller.go 79.15% <0.00%> (-1.16%) ⬇️
addons/controllers/clusterbootstrap_controller.go 63.04% <0.00%> (-0.59%) ⬇️
cmd/cli/plugin/cluster/create.go 42.22% <0.00%> (ø)
cmd/cli/plugin/cluster/osimage.go 100.00% <0.00%> (ø)
cmd/cli/plugin/cluster/get_machinehealthcheck.go 11.42% <0.00%> (ø)
cmd/cli/plugin/cluster/get_node_pools.go 10.52% <0.00%> (ø)
cmd/cli/plugin/cluster/set_node_pool.go 14.63% <0.00%> (ø)
...md/cli/plugin/cluster/delete_machinehealthcheck.go 19.23% <0.00%> (ø)
... and 21 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@marckhouzam
Copy link
Contributor Author

I will try to add tests to increase the code coverage

@chandrareddyp
Copy link
Contributor

LGTM

Copy link
Contributor

@vuil vuil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just a couple of nits on the comments in test.

cli/core/pkg/command/completion_test.go Outdated Show resolved Hide resolved
cli/core/pkg/command/completion_test.go Outdated Show resolved Hide resolved
@vuil vuil added the ok-to-merge PRs should be labelled with this before merging label Oct 25, 2022
Fixes vmware-tanzu#3158

Note also that with Cobra 1.5, it is no longer necessary
to have zsh >= 5.2 (see spf13/cobra#1665)

Signed-off-by: Marc Khouzam <kmarc@vmware.com>
@vuil vuil merged commit 7fc5101 into vmware-tanzu:main Oct 25, 2022
@marckhouzam marckhouzam deleted the feat/compFish branch October 25, 2022 21:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/core-cli area/ux UX related cla-not-required docs-triage-needed ok-to-merge PRs should be labelled with this before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support shell completion for fish shell and powershell
4 participants