@@ -589,11 +589,10 @@ private static Func<int, ConsoleColoredString> getHelpGenerator(Type type, Func<
589589 helpProcessor ??= ( s => s ) ;
590590 return wrapWidth =>
591591 {
592- int leftMargin = 3 ;
593-
594592 var helpString = new List < ConsoleColoredString > ( ) ;
595593 var commandNameAttr = type . GetCustomAttributes < CommandNameAttribute > ( ) . FirstOrDefault ( ) ;
596594 string commandName = commandNameAttr == null ? Process . GetCurrentProcess ( ) . ProcessName : "... " + commandNameAttr . Names . OrderByDescending ( c => c . Length ) . First ( ) ;
595+ var fmtOpt = type . GetCustomAttribute < HelpScreenFormattingAttribute > ( ) ;
597596
598597 //
599598 // ## CONSTRUCT THE “USAGE” LINE
@@ -651,7 +650,7 @@ private static Func<int, ConsoleColoredString> getHelpGenerator(Type type, Func<
651650 var section = field . GetCustomAttribute < SectionAttribute > ( ) ;
652651 if ( curTable == null || lastMandatory != mandatory || section != null )
653652 {
654- curTable = new TextTable { MaxWidth = wrapWidth - leftMargin , ColumnSpacing = 3 , RowSpacing = 1 , LeftMargin = leftMargin } ;
653+ curTable = new TextTable { MaxWidth = wrapWidth - fmtOpt . LeftMargin , ColumnSpacing = fmtOpt . ColumnSpacing , RowSpacing = fmtOpt . RowSpacing , LeftMargin = fmtOpt . LeftMargin } ;
655654 paramsTables . Add ( ( section ? . Heading ?? $ "{ ( mandatory ? "Required" : "Optional" ) } parameters:", curTable ) ) ;
656655 curRow = 0 ;
657656 }
@@ -661,10 +660,11 @@ private static Func<int, ConsoleColoredString> getHelpGenerator(Type type, Func<
661660
662661 foreach ( var ( heading , table ) in paramsTables )
663662 {
664- helpString . Add ( ConsoleColoredString . NewLine ) ;
663+ for ( var i = 0 ; i < fmtOpt . BlankLinesBeforeSection ; i ++ )
664+ helpString . Add ( ConsoleColoredString . NewLine ) ;
665665 helpString . Add ( new ConsoleColoredString ( heading , CmdLineColor . HelpHeading ) ) ;
666- helpString . Add ( ConsoleColoredString . NewLine ) ;
667- helpString . Add ( ConsoleColoredString . NewLine ) ;
666+ for ( var i = - 1 ; i < fmtOpt . BlankLinesAfterSection ; i ++ )
667+ helpString . Add ( ConsoleColoredString . NewLine ) ;
668668 table . RemoveEmptyColumns ( ) ;
669669 helpString . Add ( table . ToColoredString ( ) ) ;
670670 }
@@ -680,7 +680,7 @@ private static Func<int, ConsoleColoredString> getHelpGenerator(Type type, Func<
680680 }
681681 }
682682
683- return new ConsoleColoredString ( helpString . ToArray ( ) ) ;
683+ return new ConsoleColoredString ( helpString ) ;
684684 } ;
685685 }
686686
0 commit comments