Skip to content
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

Respect command mapping for help from plugins #777

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

marckhouzam
Copy link
Contributor

What this PR does / why we need it

When remapping plugin commands, the tanzu help command on those remapped commands is not correct.

For example

# The trait commands is actually remapped from "space trait"
# Notice that we are getting the help from "space" instead of "trait"
$ tz help trait
Tanzu space lifecycle management

Usage:
  tanzu space [command]

Aliases:
  space, spaces, sp

Available Commands:
  create              Create a Space with specified configuration
  delete              Delete a space
[...]

# The deploy command is remapped from "resource deploy"
# Notice that we are getting the help from "resource" instead of "deploy"
$ tz help deploy
manage resources in a Kubernetes cluster

Usage:

Flags:
  -h, --help   help for resource

Which issue(s) this PR fixes

Fixes # N/A

Describe testing done for PR

After the PR:

$ tz help trait
Trait lifecycle management

Usage:
  tanzu trait [command]

Aliases:
  trait, traits, tr

Available Commands:
  create      Create a trait with specified configuration
  delete      Delete a trait
  generate    Generate a trait manifest with specified configuration.
  get         Get details from a trait.
  list        List the traits in the current workspace.

Flags:
  -h, --help   help for trait

Global Flags:
      --no-color       deactivate color, bold, animations, and emoji output
      --project name   name of the project to use when creating resources, or switching spaces (default is project name from current-context defined by Application Engine)

Use "tanzu trait [command] --help" for more information about a command.

$ tz help deploy
Deploy resources on the cluster

Usage:
  tanzu deploy [flags]

Flags:
      --diff                Show diff
      --from-build string   Set build output directory (format: /tmp/foo)
  -h, --help                help for deploy
      --only strings        Set files or directories to patch, ignoring tanzu.yml (format: file1.yml, dirname/) (can repeat)
      --patch               Patch resources
  -y, --yes                 Confirm all prompts with yes

Notice that the invocation form is respected:

# Calling "space trait" instead of "trait" is reflected in the help
$ tz help space trait
Trait lifecycle management

Usage:
  tanzu space trait [command]
[...]

# Aliases also work
$ tz help tr
Trait lifecycle management

Usage:
  tanzu trait [command]

Aliases:
  trait, traits, tr

[...]

$ tz help space tr
Trait lifecycle management

Usage:
  tanzu space trait [command]

Aliases:
  trait, traits, tr
[...]

Release note

Respect command mapping for the help command for plugins

Additional information

Special notes for your reviewer

@marckhouzam marckhouzam requested a review from a team as a code owner June 1, 2024 14:10
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 catch, and fix!
I suggest we add a test case or two to exercise the tanzu help functionality if possible.

@marckhouzam
Copy link
Contributor Author

Nice catch, and fix! I suggest we add a test case or two to exercise the tanzu help functionality if possible.

I've added a couple of tests that fail before this change and pass after.

},
},
args: []string{"help", "dummy"},
// Output for the show-invoke-context command which prints the passed arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat :-)

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.

lgtm, thanks!

@marckhouzam marckhouzam added this to the v1.4.0 milestone Jun 4, 2024
@marckhouzam marckhouzam merged commit e3463fd into vmware-tanzu:main Jun 4, 2024
7 checks passed
@marckhouzam marckhouzam deleted the fix/helpWithRemap branch June 4, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants