Skip to content

Commit

Permalink
Fix help text to show two usages for kubernetes target plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanchajanya committed Aug 29, 2023
1 parent e3e3dc6 commit 0018389
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugin/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ var UsageFunc = func(c *cobra.Command) error {
}

// CmdTemplate is the template for plugin commands.
const CmdTemplate = `{{ bold "Usage:" }}{{if .Runnable}}
tanzu{{ $target := index .Annotations "target" }}{{ if and (ne $target "global") (ne $target "") }} {{ $target }} {{ else }} {{ end }}{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
tanzu{{ $target := index .Annotations "target" }}{{ if and (ne $target "global") (ne $target "") }} {{ $target }} {{ else }} {{ end }}{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
const CmdTemplate = `
{{ bold "Usage:" }}{{if .Runnable}}
{{ $target := index .Annotations "target" }}{{ if or (eq $target "kubernetes") (eq $target "k8s") }}tanzu {{.UseLine}}{{ end }}
{{ if and (ne $target "global") (ne $target "") }}tanzu {{ $target }} {{ else }} {{ end }}{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{ $target := index .Annotations "target" }}{{ if or (eq $target "kubernetes") (eq $target "k8s") }}tanzu {{.CommandPath}} [command]{{end}}
{{ if and (ne $target "global") (ne $target "") }}tanzu {{ $target }} {{ else }} {{ end }}{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
{{ bold "Aliases:" }}
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Expand All @@ -44,6 +47,7 @@ const CmdTemplate = `{{ bold "Usage:" }}{{if .Runnable}}
{{ bold "Additional help topics:" }}{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
{{ $target := index .Annotations "target" }}{{ if or (eq $target "kubernetes") (eq $target "k8s") }}Use "{{if beginsWith .CommandPath "tanzu "}}{{.CommandPath}}{{else}}tanzu {{.CommandPath}}{{end}} [command] --help" for more information about a command.{{end}}
Use "{{if beginsWith .CommandPath "tanzu "}}{{.CommandPath}}{{else}}tanzu{{ $target := index .Annotations "target" }}{{ if and (ne $target "global") (ne $target "") }} {{ $target }} {{ else }} {{ end }}{{.CommandPath}}{{end}} [command] --help" for more information about a command.{{end}}
`

Expand Down

0 comments on commit 0018389

Please sign in to comment.