-
Notifications
You must be signed in to change notification settings - Fork 192
Enhance Tanzu CLI completion #701
Comments
I'm taking a look at the completion for For the |
Good news, bad news for the flag completion part. Good news is I found why it wasn't working. The bad news is I don't think we can get this to behave the way we want in many cases. This appears to be a limitation of Cobra. The only time flags are included in the completion output is when they are required flags. More details in the docs here: https://github.com/spf13/cobra/blob/master/shell_completions.md#mark-flags-as-required In many of our cases, the flag is not mandatory. Things like In cases where the flag IS mandatory, completion works as expected. You can used the So it doesn't look like we can get completion for flags, though we should keep an eye on any cases where there is a required flag that we have not marked as such. The other part of this - providing completion options for things that are not commands, such as providing the list of cluster names or files, and be done. That will be a matter of going through each command and looking where there are opportunities to enhance this. There is a dynamic completion function that would need to be implemented in each of these commands for noun (https://github.com/spf13/cobra/blob/master/shell_completions.md#dynamic-completion-of-nouns) and flag (https://github.com/spf13/cobra/blob/master/shell_completions.md#specify-dynamic-flag-completion) completion options. |
We've updated to a new release of cobra that I think has some enhancements to how this is handled. It may work now, but just leaving this comment here as a breadcrumb for when I have a chance to come back to this and test things. |
Tested with a recent build and it does not appear the bump in the cobra package changed the behavior outlined here. |
As @stmcginnis pointed out we have two issues:
Let's start with the first, and look at the bug of flag names not being completed. If the
Here the version is the version of tanzu-framework used by TCE. Another problem seems to be that the Finally, for point 2 of adding dynamic completions, I think it just needs some implementation effort. I personally will soon be posting a PR for the |
Related to vmware-tanzu/tanzu-framework#701 Signed-off-by: Marc Khouzam <kmarc@vmware.com>
Tanzu CLI command completion is not fully implemented (i.e. only completes up to level 2 but not further)
As an admin I would expect e.g.
tanzu cluster kubeconfig get <TAB><TAB>
to give me the list of clusters I can choose from. But even if you add one
tanzu cluster kubeconfig get tkg-cluster-2
this will not give you the completion for
--admin
, i.e.tanzu cluster kubeconfig get tkg-cluster-2 --admin
The same is true for other
--
options (e.g.--help
) at the end for this or other commands. They are not completed. Other commands liketanzu management-cluster create <TAB><TAB>
do not provide any further options like
--ui
,--bind
or--browser
, etc. Similar fortanzu plugin install <TAB><TAB>
which does not give you options like
--local
,--help,
etc.The whole command set needs to be enhanced to give a uniform Tanzu CLI completion user experience (not just the ones I mentioned).
Affected product area
The text was updated successfully, but these errors were encountered: