@@ -14,7 +14,6 @@ public static class OptionsDebugger
1414 const string TypeNameHeader = "类型 (Type)" ;
1515 const string DescriptionHeader = "描述 (Description)" ;
1616 const string DefaultValueHeader = "默认值 (Default)" ;
17- const string HelpTextHeader = "帮助文本 (Help)" ;
1817 const string RequiredYesLabel = "是 (Yes)" ;
1918 const string RequiredNoLabel = "否 (No)" ;
2019 const string NoDescriptionLabel = "无描述 (No Description)" ;
@@ -66,14 +65,13 @@ public static void PrintParsedOptions<T>(T options) where T : class
6665 maxWidth += 2 ;
6766
6867 // 使用计算出的最大宽度进行格式化输出(表格样式)
69- var rows = new List < ( string Name , string Value , string Required , string TypeName , string Description , string DefaultValue , string HelpText ) > ( ) ;
68+ var rows = new List < ( string Name , string Value , string Required , string TypeName , string Description , string DefaultValue ) > ( ) ;
7069 int nameWidth = Math . Max ( OptionHeader . Length , maxWidth ) ;
7170 int valueWidth = ValueHeader . Length ;
7271 int requiredWidth = RequiredHeader . Length ;
7372 int typeWidth = TypeNameHeader . Length ;
7473 int descWidth = DescriptionHeader . Length ;
7574 int defaultWidth = DefaultValueHeader . Length ;
76- int helpWidth = HelpTextHeader . Length ;
7775
7876 foreach ( var ( property , displayName , optionAttribute ) in optionInfos )
7977 {
@@ -83,17 +81,15 @@ public static void PrintParsedOptions<T>(T options) where T : class
8381 var required = optionAttribute != null ? ( optionAttribute . Required ? RequiredYesLabel : RequiredNoLabel ) : string . Empty ;
8482 var description = optionAttribute != null ? ( optionAttribute . Description ?? NoDescriptionLabel ) : NoOptionAttributeLabel ;
8583 var defaultVal = optionAttribute ? . DefaultValue ? . ToString ( ) ?? string . Empty ;
86- var helpText = string . Empty ;
8784
8885 nameWidth = Math . Max ( nameWidth , displayName . Length ) ;
8986 valueWidth = Math . Max ( valueWidth , displayValue . Length ) ;
9087 requiredWidth = Math . Max ( requiredWidth , required . Length ) ;
9188 typeWidth = Math . Max ( typeWidth , typeName . Length ) ;
9289 descWidth = Math . Max ( descWidth , description . Length ) ;
9390 defaultWidth = Math . Max ( defaultWidth , defaultVal . Length ) ;
94- helpWidth = Math . Max ( helpWidth , helpText . Length ) ;
95-
96- rows . Add ( ( displayName , displayValue , required , typeName , description , defaultVal , helpText ) ) ;
91+
92+ rows . Add ( ( displayName , displayValue , required , typeName , description , defaultVal ) ) ;
9793 }
9894
9995 // 重新基于“显示宽度”计算各列宽度,中文字符按双列宽
@@ -103,15 +99,13 @@ public static void PrintParsedOptions<T>(T options) where T : class
10399 int hdType = GetDisplayWidth ( TypeNameHeader ) ;
104100 int hdDesc = GetDisplayWidth ( DescriptionHeader ) ;
105101 int hdDefault = GetDisplayWidth ( DefaultValueHeader ) ;
106- int hdHelp = GetDisplayWidth ( HelpTextHeader ) ;
107102
108103 nameWidth = Math . Max ( hdName , rows . Count > 0 ? rows . Max ( r => GetDisplayWidth ( r . Name ) ) : 0 ) ;
109104 valueWidth = Math . Max ( hdValue , rows . Count > 0 ? rows . Max ( r => GetDisplayWidth ( r . Value ) ) : 0 ) ;
110105 requiredWidth = Math . Max ( hdRequired , rows . Count > 0 ? rows . Max ( r => GetDisplayWidth ( r . Required ) ) : 0 ) ;
111106 typeWidth = Math . Max ( hdType , rows . Count > 0 ? rows . Max ( r => GetDisplayWidth ( r . TypeName ) ) : 0 ) ;
112107 descWidth = Math . Max ( hdDesc , rows . Count > 0 ? rows . Max ( r => GetDisplayWidth ( r . Description ) ) : 0 ) ;
113108 defaultWidth = Math . Max ( hdDefault , rows . Count > 0 ? rows . Max ( r => GetDisplayWidth ( r . DefaultValue ) ) : 0 ) ;
114- helpWidth = Math . Max ( hdHelp , rows . Count > 0 ? rows . Max ( r => GetDisplayWidth ( r . HelpText ) ) : 0 ) ;
115109
116110 // 限制每列最大宽度,但不得小于表头显示宽度
117111 int Limit ( int width , int max ) => Math . Min ( width , max ) ;
@@ -121,15 +115,13 @@ public static void PrintParsedOptions<T>(T options) where T : class
121115 int typeMax = Math . Max ( 18 , hdType ) ;
122116 int descMax = Math . Max ( 40 , hdDesc ) ;
123117 int defaultMax = Math . Max ( 20 , hdDefault ) ;
124- int helpMax = Math . Max ( 30 , hdHelp ) ;
125118
126119 nameWidth = Limit ( nameWidth , nameMax ) ;
127120 valueWidth = Limit ( valueWidth , valueMax ) ;
128121 requiredWidth = Limit ( requiredWidth , requiredMax ) ;
129122 typeWidth = Limit ( typeWidth , typeMax ) ;
130123 descWidth = Limit ( descWidth , descMax ) ;
131124 defaultWidth = Limit ( defaultWidth , defaultMax ) ;
132- helpWidth = Limit ( helpWidth , helpMax ) ;
133125
134126 // 记录各列最小宽度(不得压缩到小于表头显示宽度)
135127 int minNameWidth = hdName ;
@@ -138,11 +130,10 @@ public static void PrintParsedOptions<T>(T options) where T : class
138130 int minTypeWidth = hdType ;
139131 int minDescWidth = hdDesc ;
140132 int minDefaultWidth = hdDefault ;
141- int minHelpWidth = hdHelp ;
142133
143134 // 根据控制台宽度自适应整体表格宽度,确保整齐对齐
144- int columnsCount = 7 ;
145- int CalculateTotalWidth ( ) => nameWidth + valueWidth + requiredWidth + typeWidth + descWidth + defaultWidth + helpWidth + ( 2 * columnsCount ) + ( columnsCount + 1 ) ;
135+ int columnsCount = 6 ;
136+ int CalculateTotalWidth ( ) => nameWidth + valueWidth + requiredWidth + typeWidth + descWidth + defaultWidth + ( 2 * columnsCount ) + ( columnsCount + 1 ) ;
146137 int consoleWidth = 0 ;
147138 try
148139 {
@@ -162,11 +153,6 @@ public static void PrintParsedOptions<T>(T options) where T : class
162153 continue ;
163154 }
164155
165- if ( helpWidth > minHelpWidth )
166- {
167- helpWidth -- ;
168- continue ;
169- }
170156
171157 if ( valueWidth > minValueWidth )
172158 {
@@ -205,16 +191,15 @@ string BuildBorder(char left, char sep, char right, char fill)
205191 new string ( fill , requiredWidth + 2 ) , sep ,
206192 new string ( fill , typeWidth + 2 ) , sep ,
207193 new string ( fill , descWidth + 2 ) , sep ,
208- new string ( fill , defaultWidth + 2 ) , sep ,
209- new string ( fill , helpWidth + 2 ) ,
194+ new string ( fill , defaultWidth + 2 ) ,
210195 right
211196 ) ;
212197 }
213198
214199
215200 // 打印表头
216201 Console . WriteLine ( BuildBorder ( '┌' , '┬' , '┐' , '─' ) ) ;
217- Console . WriteLine ( $ "│ { TruncPadDisplay ( OptionHeader , nameWidth ) } │ { TruncPadDisplay ( ValueHeader , valueWidth ) } │ { CenterPadDisplay ( RequiredHeader , requiredWidth ) } │ { TruncPadDisplay ( TypeNameHeader , typeWidth ) } │ { TruncPadDisplay ( DescriptionHeader , descWidth ) } │ { TruncPadDisplay ( DefaultValueHeader , defaultWidth ) } │ { TruncPadDisplay ( HelpTextHeader , helpWidth ) } │ ") ;
202+ Console . WriteLine ( $ "│ { TruncPadDisplay ( OptionHeader , nameWidth ) } │ { TruncPadDisplay ( ValueHeader , valueWidth ) } │ { CenterPadDisplay ( RequiredHeader , requiredWidth ) } │ { TruncPadDisplay ( TypeNameHeader , typeWidth ) } │ { TruncPadDisplay ( DescriptionHeader , descWidth ) } │ { TruncPadDisplay ( DefaultValueHeader , defaultWidth ) } │") ;
218203 Console . WriteLine ( BuildBorder ( '├' , '┼' , '┤' , '─' ) ) ;
219204
220205 // 打印数据行
@@ -226,7 +211,6 @@ string BuildBorder(char left, char sep, char right, char fill)
226211 var typeLines = WrapToDisplayLines ( row . TypeName , typeWidth ) ;
227212 var descLines = WrapToDisplayLines ( row . Description , descWidth ) ;
228213 var defLines = WrapToDisplayLines ( row . DefaultValue , defaultWidth ) ;
229- var helpLines = WrapToDisplayLines ( row . HelpText , helpWidth ) ;
230214
231215 int lineCount = new [ ]
232216 {
@@ -235,8 +219,7 @@ string BuildBorder(char left, char sep, char right, char fill)
235219 1 ,
236220 typeLines . Count ,
237221 descLines . Count ,
238- defLines . Count ,
239- helpLines . Count
222+ defLines . Count
240223 } . Max ( ) ;
241224
242225 for ( int i = 0 ; i < lineCount ; i ++ )
@@ -247,9 +230,8 @@ string BuildBorder(char left, char sep, char right, char fill)
247230 string typeLine = i < typeLines . Count ? typeLines [ i ] : new string ( ' ' , typeWidth ) ;
248231 string descLine = i < descLines . Count ? descLines [ i ] : new string ( ' ' , descWidth ) ;
249232 string defLine = i < defLines . Count ? defLines [ i ] : new string ( ' ' , defaultWidth ) ;
250- string helpLine = i < helpLines . Count ? helpLines [ i ] : new string ( ' ' , helpWidth ) ;
251233
252- Console . WriteLine ( $ "│ { nameLine } │ { valueLine } │ { reqLine } │ { typeLine } │ { descLine } │ { defLine } │ { helpLine } │ ") ;
234+ Console . WriteLine ( $ "│ { nameLine } │ { valueLine } │ { reqLine } │ { typeLine } │ { descLine } │ { defLine } │") ;
253235 }
254236 }
255237
0 commit comments