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

Function generateSectionOptionsOutput

internal/execute/tsc/help.go:149–192  ·  view source on GitHub ↗
(
	sys System,
	locale locale.Locale,
	sectionName string,
	options []*tsoptions.CommandLineOption,
	subCategory bool,
	beforeOptionsDescription,
	afterOptionsDescription *string,
)

Source from the content-addressed store, hash-verified

147}
148
149func generateSectionOptionsOutput(
150 sys System,
151 locale locale.Locale,
152 sectionName string,
153 options []*tsoptions.CommandLineOption,
154 subCategory bool,
155 beforeOptionsDescription,
156 afterOptionsDescription *string,
157) (output []string) {
158 output = append(output, createColors(sys).bold(sectionName), "\n", "\n")
159
160 if beforeOptionsDescription != nil {
161 output = append(output, *beforeOptionsDescription, "\n", "\n")
162 }
163 if !subCategory {
164 output = append(output, generateGroupOptionOutput(sys, locale, options)...)
165 if afterOptionsDescription != nil {
166 output = append(output, *afterOptionsDescription, "\n", "\n")
167 }
168 return output
169 }
170 categoryMap := make(map[string][]*tsoptions.CommandLineOption)
171 var categoryOrder []string
172 for _, option := range options {
173 if option.Category == nil {
174 continue
175 }
176 curCategory := option.Category.Localize(locale)
177 if _, exists := categoryMap[curCategory]; !exists {
178 categoryOrder = append(categoryOrder, curCategory)
179 }
180 categoryMap[curCategory] = append(categoryMap[curCategory], option)
181 }
182 for _, key := range categoryOrder {
183 value := categoryMap[key]
184 output = append(output, "### ", key, "\n", "\n")
185 output = append(output, generateGroupOptionOutput(sys, locale, value)...)
186 }
187 if afterOptionsDescription != nil {
188 output = append(output, *afterOptionsDescription, "\n", "\n")
189 }
190
191 return output
192}
193
194func generateGroupOptionOutput(sys System, locale locale.Locale, optionsList []*tsoptions.CommandLineOption) []string {
195 var maxLength int

Callers 3

printEasyHelpFunction · 0.85
printAllHelpFunction · 0.85
PrintBuildHelpFunction · 0.85

Calls 6

createColorsFunction · 0.85
boldMethod · 0.65
LocalizeMethod · 0.65
appendFunction · 0.50
makeFunction · 0.50

Tested by

no test coverage detected