github.com/jfrog/frogbot/v2@v2.21.0/utils/outputwriter/standardoutput.go (about)

     1  package outputwriter
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  type StandardOutput struct {
     9  	MarkdownOutput
    10  }
    11  
    12  func (so *StandardOutput) Separator() string {
    13  	return "<br>"
    14  }
    15  
    16  func (so *StandardOutput) FormattedSeverity(severity, applicability string) string {
    17  	return fmt.Sprintf("%s%8s", getSeverityTag(IconName(severity), applicability), severity)
    18  }
    19  
    20  func (so *StandardOutput) Image(source ImageSource) string {
    21  	if so.hasInternetConnection {
    22  		return GetBanner(source)
    23  	}
    24  	return MarkAsBold(GetSimplifiedTitle(source))
    25  }
    26  
    27  func (so *StandardOutput) MarkInCenter(content string) string {
    28  	return GetMarkdownCenterTag(content)
    29  }
    30  
    31  func (so *StandardOutput) MarkAsDetails(summary string, subTitleDepth int, content string) string {
    32  	if summary != "" {
    33  		summary = fmt.Sprintf("<summary> <b>%s</b> </summary>\n", summary)
    34  	}
    35  	if subTitleDepth > 0 {
    36  		summary += "<br>\n"
    37  	}
    38  	return fmt.Sprintf("<details>\n%s\n%s\n\n</details>\n", summary, content)
    39  }
    40  
    41  func (so *StandardOutput) MarkAsTitle(title string, subTitleDepth int) string {
    42  	if subTitleDepth == 0 {
    43  		return title
    44  	}
    45  	return fmt.Sprintf("%s %s", strings.Repeat("#", subTitleDepth), title)
    46  }
    47  
    48  func GetMarkdownCenterTag(content string) string {
    49  	return fmt.Sprintf("<div align='center'>\n\n%s\n\n</div>\n", content)
    50  }