@@ -47,21 +47,20 @@ public void PrintCommand(string name, ICommandLineCommandContainer container)
4747 PrintCommandDescriptions ( container . Commands ) ;
4848 }
4949
50- public void PrintCommandDescription ( ICommandLineCommand command , int descriptionShift = 4 )
51- => stringBuilder . AppendLine ( $ " { command . Name } { new string ( ' ' , descriptionShift ) } { command . Description } ") ;
50+ public void PrintCommandDescription ( ICommandLineCommand command )
51+ => stringBuilder . AppendLine ( $ " { command . Name , - 20 } { command . Description , - 50 } ") ;
5252
53- public void PrintCommandDescriptions ( IEnumerable < ICommandLineCommand > commands , int descriptionShift = 4 )
53+ public void PrintCommandDescriptions ( IEnumerable < ICommandLineCommand > commands )
5454 {
5555 if ( ! commands . Any ( ) ) return ;
5656
5757 stringBuilder . AppendLine ( ) . AppendLine ( "Commands: " ) ;
5858
59- var longestCommandName = commands . Max ( x => x . Name . Length ) ;
6059 foreach ( var cmd in commands )
61- PrintCommandDescription ( cmd , longestCommandName - cmd . Name . Length + descriptionShift ) ;
60+ PrintCommandDescription ( cmd ) ;
6261 }
6362
64- public void PrintOption ( ICommandLineOption option , int descriptionShift = 4 , bool compensateSeparator = false )
63+ public void PrintOption ( ICommandLineOption option )
6564 {
6665 bool hasShort = option . HasShortName ;
6766 bool hasLong = option . HasLongName ;
@@ -71,29 +70,20 @@ public void PrintOption(ICommandLineOption option, int descriptionShift = 4, boo
7170 string shortName = hasShort ? option . ShortName : string . Empty ;
7271 string longName = hasLong ? option . LongName : string . Empty ;
7372
74- // We neeed to compensate a separator if given option doesn't have both (short & long) names.
75- int indentationLength = descriptionShift + ( ( compensateSeparator && ! hasBoth ) ? optionSeparator . Length : 0 ) ;
76- string indentation = new string ( ' ' , indentationLength ) ;
73+ string key = $ "{ shortName } { hasBothSeparator } { longName } ";
7774
78- stringBuilder . AppendLine ( $ " { shortName } { hasBothSeparator } { longName } { indentation } { option . Description } ") ;
75+ stringBuilder . AppendLine ( $ " { key , - 20 } { option . Description , - 50 } ") ;
7976 }
8077
81- public void PrintOptions ( IEnumerable < ICommandLineOption > options , int descriptionShift = 4 )
78+ public void PrintOptions ( IEnumerable < ICommandLineOption > options )
8279 {
8380 if ( ! options . Any ( ) ) return ;
8481
8582 stringBuilder . AppendLine ( ) . AppendLine ( "Options: " ) ;
8683
87- var longestOptionName = options . Max ( x => ( x . HasShortName ? x . ShortName . Length : 0 ) + ( x . HasLongName ? x . LongName . Length : 0 ) ) ;
88- var compensateSeparator = options . Any ( x => x . HasShortName && x . HasLongName ) ;
89-
9084 foreach ( var opt in options )
91- {
92- var longNameLength = opt . HasLongName ? opt . LongName . Length : 0 ;
93- var shortNameLength = opt . HasShortName ? opt . ShortName . Length : 0 ;
94- descriptionShift = longestOptionName - longNameLength - shortNameLength + descriptionShift ;
95-
96- PrintOption ( opt , descriptionShift , compensateSeparator ) ;
85+ {
86+ PrintOption ( opt ) ;
9787 }
9888 }
9989 }
0 commit comments