diff --git a/plugin/usage.go b/plugin/usage.go index 3b173dbe..6c638543 100644 --- a/plugin/usage.go +++ b/plugin/usage.go @@ -289,7 +289,11 @@ func printHelp(cmd *cobra.Command) string { if cmd.HasExample() { output.WriteString("\n" + component.Bold(examplesStr) + "\n") - output.WriteString(indentStr + cmd.Example + "\n") + + // matches cobra default help template's behavior of not indenting the + // Example value, which has the added benefit of ensuring multiline + // .Example values are aligned + output.WriteString(cmd.Example + "\n") } if cmd.HasAvailableSubCommands() { diff --git a/plugin/usage_test.go b/plugin/usage_test.go index 99c8e5de..7c008b23 100644 --- a/plugin/usage_test.go +++ b/plugin/usage_test.go @@ -113,7 +113,7 @@ func usageTestPlugin(t *testing.T, target types.Target) *Plugin { fetchCmd.Example = "sample example usage of the fetch command" - pushCmd.Example = "sample example usage of the push command" + pushCmd.Example = "sample example usage of the push command\nmore sample example usage of the push command" p, err := NewPlugin(&descriptor) assert.Nil(t, err) @@ -179,7 +179,7 @@ Aliases: test, t Examples: - sample example usage of the test command +sample example usage of the test command Available Commands: fetch Fetch the plugin tests @@ -240,7 +240,7 @@ Aliases: test, t Examples: - sample example usage of the test command +sample example usage of the test command Available Commands: fetch Fetch the plugin tests @@ -301,7 +301,7 @@ Aliases: test, t Examples: - sample example usage of the test command +sample example usage of the test command Available Commands: fetch Fetch the plugin tests @@ -357,7 +357,7 @@ Usage: tanzu test fetch [flags] Examples: - sample example usage of the fetch command +sample example usage of the fetch command Flags: -h, --help help for fetch @@ -415,7 +415,7 @@ Usage: tanzu fetch [flags] Examples: - sample example usage of the fetch command +sample example usage of the fetch command Flags: -h, --help help for fetch @@ -469,7 +469,7 @@ Usage: tanzu kubernetes test fetch [flags] Examples: - sample example usage of the fetch command +sample example usage of the fetch command Flags: -h, --help help for fetch @@ -521,7 +521,7 @@ Usage: tanzu mission-control test fetch [flags] Examples: - sample example usage of the fetch command +sample example usage of the fetch command Flags: -h, --help help for fetch @@ -584,7 +584,8 @@ Aliases: pu, psh Examples: - sample example usage of the push command +sample example usage of the push command +more sample example usage of the push command Available Commands: more Push more