Skip to content

Commit

Permalink
Merge pull request #3976 from thaJeztah/20.10_backport_no_escape
Browse files Browse the repository at this point in the history
[20.10 backport] cli: additionalHelp() don't decorate output if it's piped, and add extra newline
  • Loading branch information
thaJeztah authored Jan 18, 2023
2 parents 91c1ac4 + 913fa47 commit d4cfac0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cli/cobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,13 @@ func isExperimental(cmd *cobra.Command) bool {
}

func additionalHelp(cmd *cobra.Command) string {
if additionalHelp, ok := cmd.Annotations["additionalHelp"]; ok {
if msg, ok := cmd.Annotations["additionalHelp"]; ok {
out := cmd.OutOrStderr()
if _, isTerminal := term.GetFdInfo(out); !isTerminal {
return msg
}
style := aec.EmptyBuilder.Bold().ANSI
return style.Apply(additionalHelp)
return style.Apply(msg)
}
return ""
}
Expand Down Expand Up @@ -379,6 +383,7 @@ Run '{{.CommandPath}} COMMAND --help' for more information on a command.
{{- if hasAdditionalHelp .}}
{{ additionalHelp . }}
{{- end}}
`

Expand Down

0 comments on commit d4cfac0

Please sign in to comment.