Skip to content

Commit

Permalink
Remove indent when generating Example lines in usage
Browse files Browse the repository at this point in the history
Signed-off-by: Vui Lam <vui.lam@broadcom.com>
  • Loading branch information
vuil committed May 3, 2024
1 parent ad724a2 commit 99df044
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 5 additions & 1 deletion plugin/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
19 changes: 10 additions & 9 deletions plugin/usage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 99df044

Please sign in to comment.