@@ -644,7 +644,7 @@ private static Func<int, ConsoleColoredString> getHelpGenerator(Type type, Func<
644644 //
645645
646646 var anyCommandsWithSuboptions = false ;
647- var paramsTables = new List < ( string heading , TextTable table ) > ( ) ;
647+ var paramsTables = new List < ( ConsoleColoredString heading , TextTable table ) > ( ) ;
648648 TextTable curTable = null ;
649649 var curRow = 0 ;
650650 var lastMandatory = false ;
@@ -653,11 +653,13 @@ private static Func<int, ConsoleColoredString> getHelpGenerator(Type type, Func<
653653 . Concat ( optionalPositional . Select ( fld => ( mandatory : false , positional : true , field : fld ) ) )
654654 . Concat ( optionalOptions . Select ( fld => ( mandatory : false , positional : false , field : fld ) ) ) )
655655 {
656- var section = field . GetCustomAttribute < SectionAttribute > ( ) ;
657- if ( curTable == null || lastMandatory != mandatory || section != null )
656+ var sectionHeading = (
657+ field . GetCustomAttribute < SectionAttribute > ( ) is { } sec ? sec . Heading . Color ( CmdLineColor . HelpHeading ) :
658+ field . GetCustomAttribute < SectionEggsMLAttribute > ( ) is { } egg ? Colorize ( EggsML . Parse ( egg . Heading ) ) : null ) ;
659+ if ( curTable == null || lastMandatory != mandatory || sectionHeading != null )
658660 {
659661 curTable = new TextTable { MaxWidth = wrapWidth - fmtOpt . LeftMargin , ColumnSpacing = fmtOpt . ColumnSpacing , RowSpacing = fmtOpt . RowSpacing , LeftMargin = fmtOpt . LeftMargin , StretchLastCell = true } ;
660- paramsTables . Add ( ( section ? . Heading ?? $ "{ ( mandatory ? "Required" : "Optional" ) } parameters:", curTable ) ) ;
662+ paramsTables . Add ( ( sectionHeading ?? $ "{ ( mandatory ? "Required" : "Optional" ) } parameters:". Color ( CmdLineColor . HelpHeading ) , curTable ) ) ;
661663 curRow = 0 ;
662664 }
663665 anyCommandsWithSuboptions |= createParameterHelpRow ( ref curRow , curTable , field , positional , helpProcessor ) ;
@@ -668,7 +670,7 @@ private static Func<int, ConsoleColoredString> getHelpGenerator(Type type, Func<
668670 {
669671 for ( var i = 0 ; i < fmtOpt . BlankLinesBeforeSection ; i ++ )
670672 helpString . Add ( ConsoleColoredString . NewLine ) ;
671- helpString . Add ( new ConsoleColoredString ( heading , CmdLineColor . HelpHeading ) ) ;
673+ helpString . Add ( heading ) ;
672674 for ( var i = - 1 ; i < fmtOpt . BlankLinesAfterSection ; i ++ )
673675 helpString . Add ( ConsoleColoredString . NewLine ) ;
674676 table . RemoveEmptyColumns ( ) ;
0 commit comments