@@ -47,21 +47,20 @@ public void PrintCommand(string name, ICommandLineCommandContainer container)
47
47
PrintCommandDescriptions ( container . Commands ) ;
48
48
}
49
49
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 } ") ;
52
52
53
- public void PrintCommandDescriptions ( IEnumerable < ICommandLineCommand > commands , int descriptionShift = 4 )
53
+ public void PrintCommandDescriptions ( IEnumerable < ICommandLineCommand > commands )
54
54
{
55
55
if ( ! commands . Any ( ) ) return ;
56
56
57
57
stringBuilder . AppendLine ( ) . AppendLine ( "Commands: " ) ;
58
58
59
- var longestCommandName = commands . Max ( x => x . Name . Length ) ;
60
59
foreach ( var cmd in commands )
61
- PrintCommandDescription ( cmd , longestCommandName - cmd . Name . Length + descriptionShift ) ;
60
+ PrintCommandDescription ( cmd ) ;
62
61
}
63
62
64
- public void PrintOption ( ICommandLineOption option , int descriptionShift = 4 , bool compensateSeparator = false )
63
+ public void PrintOption ( ICommandLineOption option )
65
64
{
66
65
bool hasShort = option . HasShortName ;
67
66
bool hasLong = option . HasLongName ;
@@ -71,29 +70,20 @@ public void PrintOption(ICommandLineOption option, int descriptionShift = 4, boo
71
70
string shortName = hasShort ? option . ShortName : string . Empty ;
72
71
string longName = hasLong ? option . LongName : string . Empty ;
73
72
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 } ";
77
74
78
- stringBuilder . AppendLine ( $ " { shortName } { hasBothSeparator } { longName } { indentation } { option . Description } ") ;
75
+ stringBuilder . AppendLine ( $ " { key , - 20 } { option . Description , - 50 } ") ;
79
76
}
80
77
81
- public void PrintOptions ( IEnumerable < ICommandLineOption > options , int descriptionShift = 4 )
78
+ public void PrintOptions ( IEnumerable < ICommandLineOption > options )
82
79
{
83
80
if ( ! options . Any ( ) ) return ;
84
81
85
82
stringBuilder . AppendLine ( ) . AppendLine ( "Options: " ) ;
86
83
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
-
90
84
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 ) ;
97
87
}
98
88
}
99
89
}
0 commit comments