@@ -18,6 +18,7 @@ public IEnumerable<Action<HelpContext>> CustomHelpLayout()
1818 {
1919 yield return ( context ) =>
2020 {
21+ WriteHelpOptions ( context ) ;
2122 Console . WriteLine ( LocalizableStrings . HelpWaitingForOptionsAndExtensions ) ;
2223
2324 Run ( context . ParseResult ) ;
@@ -27,43 +28,24 @@ public IEnumerable<Action<HelpContext>> CustomHelpLayout()
2728 return ;
2829 }
2930
30- WriteCustomHelp ( context ) ;
31- } ;
32- }
31+ Dictionary < bool , List < CommandLineOption > > allOptions = GetAllOptions ( ) ;
32+ allOptions . TryGetValue ( true , out List < CommandLineOption > builtInOptions ) ;
33+ allOptions . TryGetValue ( false , out List < CommandLineOption > nonBuiltInOptions ) ;
3334
34- private void WriteCustomHelp ( HelpContext context )
35- {
36- var allOptions = GetAllOptions ( ) ;
37- var builtInOptions = GetOptionNames ( allOptions , isBuiltIn : true ) ;
38- var nonBuiltInOptions = GetOptionNames ( allOptions , isBuiltIn : false ) ;
39- var moduleToMissingOptions = GetModulesToMissingOptions ( _moduleNamesToCommandLineOptions , builtInOptions , nonBuiltInOptions ) ;
35+ Dictionary < bool , List < ( string [ ] , string [ ] ) > > moduleToMissingOptions = GetModulesToMissingOptions ( _moduleNamesToCommandLineOptions , builtInOptions . Select ( option => option . Name ) , nonBuiltInOptions . Select ( option => option . Name ) ) ;
4036
41- WriteHelpSections ( context , allOptions , moduleToMissingOptions ) ;
37+ _output . WritePlatformAndExtensionOptions ( context , builtInOptions , nonBuiltInOptions , moduleToMissingOptions ) ;
38+ } ;
4239 }
4340
44- private static IEnumerable < string > GetOptionNames ( Dictionary < bool , List < CommandLineOption > > allOptions , bool isBuiltIn ) => allOptions . TryGetValue ( isBuiltIn , out var options ) ? options . Select ( option => option . Name ) : [ ] ;
45-
46- private void WriteHelpSections ( HelpContext context , Dictionary < bool , List < CommandLineOption > > allOptions , Dictionary < bool , List < ( string [ ] , string [ ] ) > > moduleToMissingOptions )
41+ private void WriteHelpOptions ( HelpContext context )
4742 {
4843 HelpBuilder . Default . SynopsisSection ( ) ( context ) ;
4944 context . Output . WriteLine ( ) ;
5045 WriteUsageSection ( context ) ;
5146 context . Output . WriteLine ( ) ;
5247 HelpBuilder . Default . OptionsSection ( ) ( context ) ;
5348 context . Output . WriteLine ( ) ;
54-
55- if ( allOptions . TryGetValue ( true , out var builtInOptions ) && builtInOptions . Count > 0 )
56- {
57- WriteOtherOptionsSection ( context , LocalizableStrings . HelpPlatformOptions , builtInOptions ) ;
58- context . Output . WriteLine ( ) ;
59- }
60-
61- if ( allOptions . TryGetValue ( false , out var extensionOptions ) && extensionOptions . Count > 0 )
62- {
63- WriteOtherOptionsSection ( context , LocalizableStrings . HelpExtensionOptions , extensionOptions ) ;
64- context . Output . WriteLine ( ) ;
65- }
66- _output . WriteModulesToMissingOptionsToConsole ( moduleToMissingOptions ) ;
6749 }
6850
6951 private static void WriteUsageSection ( HelpContext context )
@@ -109,25 +91,6 @@ private static string FormatHelpOption(string option)
10991 return $ "[{ option . Trim ( ':' ) . ToLower ( ) } ]";
11092 }
11193
112- private void WriteOtherOptionsSection ( HelpContext context , string title , List < CommandLineOption > options )
113- {
114- List < TwoColumnHelpRow > optionRows = [ ] ;
115-
116- foreach ( var option in options )
117- {
118- if ( ( bool ) ! option . IsHidden )
119- {
120- optionRows . Add ( new TwoColumnHelpRow ( $ "--{ option . Name } ", option . Description ) ) ;
121- }
122- }
123-
124- if ( optionRows . Count > 0 )
125- {
126- _output . WriteHeading ( title , null ) ;
127- context . HelpBuilder . WriteColumns ( optionRows , context ) ;
128- }
129- }
130-
13194 private void OnHelpRequested ( object sender , HelpEventArgs args )
13295 {
13396 CommandLineOption [ ] commandLineOptionMessages = args . CommandLineOptions ;
0 commit comments