Merge pull request #3976 from thaJeztah/20.10_backport_no_escape

[20.10 backport] cli: additionalHelp() don't decorate output if it's piped, and add extra newline
This commit is contained in:
Sebastiaan van Stijn 2023-01-18 15:56:05 +01:00 committed by GitHub
commit d4cfac0100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -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 ""
}
@ -379,6 +383,7 @@ Run '{{.CommandPath}} COMMAND --help' for more information on a command.
{{- if hasAdditionalHelp .}}
{{ additionalHelp . }}
{{- end}}
`