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

Function generateGroupOptionOutput

internal/execute/tsc/help.go:194–220  ·  view source on GitHub ↗
(sys System, locale locale.Locale, optionsList []*tsoptions.CommandLineOption)

Source from the content-addressed store, hash-verified

192}
193
194func generateGroupOptionOutput(sys System, locale locale.Locale, optionsList []*tsoptions.CommandLineOption) []string {
195 var maxLength int
196 for _, option := range optionsList {
197 curLenght := len(getDisplayNameTextOfOption(option))
198 maxLength = max(curLenght, maxLength)
199 }
200
201 // left part should be right align, right part should be left align
202
203 // assume 2 space between left margin and left part.
204 rightAlignOfLeftPart := maxLength + 2
205 // assume 2 space between left and right part
206 leftAlignOfRightPart := rightAlignOfLeftPart + 2
207
208 var lines []string
209 for _, option := range optionsList {
210 tmp := generateOptionOutput(sys, locale, option, rightAlignOfLeftPart, leftAlignOfRightPart)
211 lines = append(lines, tmp...)
212 }
213
214 // make sure always a blank line in the end.
215 if len(lines) < 2 || lines[len(lines)-2] != "\n" {
216 lines = append(lines, "\n")
217 }
218
219 return lines
220}
221
222func generateOptionOutput(
223 sys System,

Callers 1

Calls 5

lenFunction · 0.85
maxFunction · 0.85
generateOptionOutputFunction · 0.85
appendFunction · 0.50

Tested by

no test coverage detected