Skip to content

Commit 80d537a

Browse files
Copilotjakebailey
andauthored
Implement printAllHelp to fix tsgo --all producing no output (#1843)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jakebailey <[email protected]>
1 parent fc800a7 commit 80d537a

File tree

6 files changed

+684
-8
lines changed

6 files changed

+684
-8
lines changed

internal/execute/tsc/help.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func PrintHelp(sys System, commandLine *tsoptions.ParsedCommandLine) {
1919
if commandLine.CompilerOptions().All.IsFalseOrUnknown() {
2020
printEasyHelp(sys, getOptionsForHelp(commandLine))
2121
} else {
22-
// !!! printAllHelp(sys, getOptionsForHelp(commandLine))
22+
printAllHelp(sys, getOptionsForHelp(commandLine))
2323
}
2424
}
2525

@@ -107,6 +107,31 @@ func printEasyHelp(sys System, simpleOptions []*tsoptions.CommandLineOption) {
107107
}
108108
}
109109

110+
func printAllHelp(sys System, options []*tsoptions.CommandLineOption) {
111+
var output []string
112+
msg := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format() + " - " + diagnostics.Version_0.Format(core.Version())
113+
output = append(output, getHeader(sys, msg)...)
114+
115+
// ALL COMPILER OPTIONS section
116+
afterCompilerOptions := diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0.Format("https://aka.ms/tsc")
117+
output = append(output, generateSectionOptionsOutput(sys, diagnostics.ALL_COMPILER_OPTIONS.Format(), options, true, nil, &afterCompilerOptions)...)
118+
119+
// WATCH OPTIONS section
120+
beforeWatchOptions := diagnostics.Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon.Format()
121+
output = append(output, generateSectionOptionsOutput(sys, diagnostics.WATCH_OPTIONS.Format(), tsoptions.OptionsForWatch, false, &beforeWatchOptions, nil)...)
122+
123+
// BUILD OPTIONS section
124+
beforeBuildOptions := diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0.Format("https://aka.ms/tsc-composite-builds")
125+
buildOptions := core.Filter(tsoptions.OptionsForBuild, func(option *tsoptions.CommandLineOption) bool {
126+
return option != &tsoptions.TscBuildOption
127+
})
128+
output = append(output, generateSectionOptionsOutput(sys, diagnostics.BUILD_OPTIONS.Format(), buildOptions, false, &beforeBuildOptions, nil)...)
129+
130+
for _, chunk := range output {
131+
fmt.Fprint(sys.Writer(), chunk)
132+
}
133+
}
134+
110135
func PrintBuildHelp(sys System, buildOptions []*tsoptions.CommandLineOption) {
111136
var output []string
112137
output = append(output, getHeader(sys, diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format()+" - "+diagnostics.Version_0.Format(core.Version()))...)
@@ -142,14 +167,19 @@ func generateSectionOptionsOutput(
142167
return output
143168
}
144169
categoryMap := make(map[string][]*tsoptions.CommandLineOption)
170+
var categoryOrder []string
145171
for _, option := range options {
146172
if option.Category == nil {
147173
continue
148174
}
149175
curCategory := option.Category.Format()
176+
if _, exists := categoryMap[curCategory]; !exists {
177+
categoryOrder = append(categoryOrder, curCategory)
178+
}
150179
categoryMap[curCategory] = append(categoryMap[curCategory], option)
151180
}
152-
for key, value := range categoryMap {
181+
for _, key := range categoryOrder {
182+
value := categoryMap[key]
153183
output = append(output, "### ", key, "\n", "\n")
154184
output = append(output, generateGroupOptionOutput(sys, value)...)
155185
}

internal/tsoptions/declsbuild.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"github.com/microsoft/typescript-go/internal/diagnostics"
77
)
88

9-
var BuildOpts = slices.Concat(commonOptionsWithBuild, optionsForBuild)
10-
119
var TscBuildOption = CommandLineOption{
1210
Name: "build",
1311
Kind: "boolean",
@@ -18,7 +16,7 @@ var TscBuildOption = CommandLineOption{
1816
DefaultValueDescription: false,
1917
}
2018

21-
var optionsForBuild = []*CommandLineOption{
19+
var OptionsForBuild = []*CommandLineOption{
2220
&TscBuildOption,
2321
{
2422
Name: "verbose",
@@ -59,3 +57,5 @@ var optionsForBuild = []*CommandLineOption{
5957
DefaultValueDescription: false,
6058
},
6159
}
60+
61+
var BuildOpts = slices.Concat(commonOptionsWithBuild, OptionsForBuild)

internal/tsoptions/declswatch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"github.com/microsoft/typescript-go/internal/diagnostics"
66
)
77

8-
var optionsForWatch = []*CommandLineOption{
8+
var OptionsForWatch = []*CommandLineOption{
99
{
1010
Name: "watchInterval",
1111
Kind: CommandLineOptionTypeNumber,

internal/tsoptions/diagnostics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func getParseCommandLineWorkerDiagnostics(decls []*CommandLineOption) *ParseComm
4646
var watchOptionsDidYouMeanDiagnostics = &ParseCommandLineWorkerDiagnostics{
4747
didYouMean: DidYouMeanOptionsDiagnostics{
4848
// no alternateMode
49-
OptionDeclarations: optionsForWatch,
49+
OptionDeclarations: OptionsForWatch,
5050
UnknownOptionDiagnostic: diagnostics.Unknown_watch_option_0,
5151
UnknownDidYouMeanDiagnostic: diagnostics.Unknown_watch_option_0_Did_you_mean_1,
5252
},

internal/tsoptions/namemap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
var (
1010
CompilerNameMap = GetNameMapFromList(OptionsDeclarations)
1111
BuildNameMap = GetNameMapFromList(BuildOpts)
12-
WatchNameMap = GetNameMapFromList(optionsForWatch)
12+
WatchNameMap = GetNameMapFromList(OptionsForWatch)
1313
)
1414

1515
func GetNameMapFromList(optDecls []*CommandLineOption) *NameMap {

0 commit comments

Comments
 (0)