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 2, 2024
1 parent ad724a2 commit 68d7c2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 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
16 changes: 8 additions & 8 deletions plugin/usage_test.go
Original file line number Diff line number Diff line change
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,7 @@ Aliases:
pu, psh
Examples:
sample example usage of the push command
sample example usage of the push command
Available Commands:
more Push more
Expand Down

0 comments on commit 68d7c2f

Please sign in to comment.