Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions internal/execute/tsc/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func PrintHelp(sys System, commandLine *tsoptions.ParsedCommandLine) {
if commandLine.CompilerOptions().All.IsFalseOrUnknown() {
printEasyHelp(sys, getOptionsForHelp(commandLine))
} else {
// !!! printAllHelp(sys, getOptionsForHelp(commandLine))
printAllHelp(sys, getOptionsForHelp(commandLine))
}
}

Expand Down Expand Up @@ -107,6 +107,31 @@ func printEasyHelp(sys System, simpleOptions []*tsoptions.CommandLineOption) {
}
}

func printAllHelp(sys System, options []*tsoptions.CommandLineOption) {
var output []string
msg := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format() + " - " + diagnostics.Version_0.Format(core.Version())
output = append(output, getHeader(sys, msg)...)

// ALL COMPILER OPTIONS section
afterCompilerOptions := diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0.Format("https://aka.ms/tsc")
output = append(output, generateSectionOptionsOutput(sys, diagnostics.ALL_COMPILER_OPTIONS.Format(), options, true, nil, &afterCompilerOptions)...)

// WATCH OPTIONS section
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()
output = append(output, generateSectionOptionsOutput(sys, diagnostics.WATCH_OPTIONS.Format(), tsoptions.OptionsForWatch, false, &beforeWatchOptions, nil)...)

// BUILD OPTIONS section
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")
buildOptions := core.Filter(tsoptions.OptionsForBuild, func(option *tsoptions.CommandLineOption) bool {
return option != &tsoptions.TscBuildOption
})
output = append(output, generateSectionOptionsOutput(sys, diagnostics.BUILD_OPTIONS.Format(), buildOptions, false, &beforeBuildOptions, nil)...)

for _, chunk := range output {
fmt.Fprint(sys.Writer(), chunk)
}
}

func PrintBuildHelp(sys System, buildOptions []*tsoptions.CommandLineOption) {
var output []string
output = append(output, getHeader(sys, diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format()+" - "+diagnostics.Version_0.Format(core.Version()))...)
Expand Down Expand Up @@ -142,14 +167,19 @@ func generateSectionOptionsOutput(
return output
}
categoryMap := make(map[string][]*tsoptions.CommandLineOption)
var categoryOrder []string
for _, option := range options {
if option.Category == nil {
continue
}
curCategory := option.Category.Format()
if _, exists := categoryMap[curCategory]; !exists {
categoryOrder = append(categoryOrder, curCategory)
}
categoryMap[curCategory] = append(categoryMap[curCategory], option)
}
for key, value := range categoryMap {
for _, key := range categoryOrder {
value := categoryMap[key]
output = append(output, "### ", key, "\n", "\n")
output = append(output, generateGroupOptionOutput(sys, value)...)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/tsoptions/declsbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"github.com/microsoft/typescript-go/internal/diagnostics"
)

var BuildOpts = slices.Concat(commonOptionsWithBuild, optionsForBuild)

var TscBuildOption = CommandLineOption{
Name: "build",
Kind: "boolean",
Expand All @@ -18,7 +16,7 @@ var TscBuildOption = CommandLineOption{
DefaultValueDescription: false,
}

var optionsForBuild = []*CommandLineOption{
var OptionsForBuild = []*CommandLineOption{
&TscBuildOption,
{
Name: "verbose",
Expand Down Expand Up @@ -59,3 +57,5 @@ var optionsForBuild = []*CommandLineOption{
DefaultValueDescription: false,
},
}

var BuildOpts = slices.Concat(commonOptionsWithBuild, OptionsForBuild)
2 changes: 1 addition & 1 deletion internal/tsoptions/declswatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/microsoft/typescript-go/internal/diagnostics"
)

var optionsForWatch = []*CommandLineOption{
var OptionsForWatch = []*CommandLineOption{
{
Name: "watchInterval",
Kind: CommandLineOptionTypeNumber,
Expand Down
2 changes: 1 addition & 1 deletion internal/tsoptions/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func getParseCommandLineWorkerDiagnostics(decls []*CommandLineOption) *ParseComm
var watchOptionsDidYouMeanDiagnostics = &ParseCommandLineWorkerDiagnostics{
didYouMean: DidYouMeanOptionsDiagnostics{
// no alternateMode
OptionDeclarations: optionsForWatch,
OptionDeclarations: OptionsForWatch,
UnknownOptionDiagnostic: diagnostics.Unknown_watch_option_0,
UnknownDidYouMeanDiagnostic: diagnostics.Unknown_watch_option_0_Did_you_mean_1,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/tsoptions/namemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var (
CompilerNameMap = GetNameMapFromList(OptionsDeclarations)
BuildNameMap = GetNameMapFromList(BuildOpts)
WatchNameMap = GetNameMapFromList(optionsForWatch)
WatchNameMap = GetNameMapFromList(OptionsForWatch)
)

func GetNameMapFromList(optDecls []*CommandLineOption) *NameMap {
Expand Down
Loading