MCPcopy Create free account
hub / github.com/microsoft/typescript-go / getHeader

Function getHeader

internal/execute/tsc/help.go:44–65  ·  view source on GitHub ↗
(sys System, message string)

Source from the content-addressed store, hash-verified

42}
43
44func getHeader(sys System, message string) []string {
45 colors := createColors(sys)
46 header := make([]string, 0, 3)
47 terminalWidth := sys.GetWidthOfTerminal()
48 const tsIcon = " "
49 const tsIconTS = " TS "
50 const tsIconLength = len(tsIcon)
51
52 tsIconFirstLine := colors.blueBackground(tsIcon)
53 tsIconSecondLine := colors.blueBackground(colors.brightWhite(tsIconTS))
54 // If we have enough space, print TS icon.
55 if terminalWidth >= len(message)+tsIconLength {
56 // right align of the icon is 120 at most.
57 rightAlign := core.IfElse(terminalWidth > 120, 120, terminalWidth)
58 leftAlign := rightAlign - tsIconLength
59 header = append(header, fmt.Sprintf("%-*s", leftAlign, message), tsIconFirstLine, "\n")
60 header = append(header, strings.Repeat(" ", leftAlign), tsIconSecondLine, "\n")
61 } else {
62 header = append(header, message, "\n", "\n")
63 }
64 return header
65}
66
67func printEasyHelp(sys System, locale locale.Locale, simpleOptions []*tsoptions.CommandLineOption) {
68 colors := createColors(sys)

Callers 4

printEasyHelpFunction · 0.85
printAllHelpFunction · 0.85
PrintBuildHelpFunction · 0.85
WriteConfigFileFunction · 0.85

Calls 8

IfElseFunction · 0.92
createColorsFunction · 0.85
lenFunction · 0.85
blueBackgroundMethod · 0.80
brightWhiteMethod · 0.80
GetWidthOfTerminalMethod · 0.65
makeFunction · 0.50
appendFunction · 0.50

Tested by

no test coverage detected