Skip to content

Commit a5017fc

Browse files
committed
refactor(OptionsDebugger): 移除重复的边框打印并重构为独立方法
将重复的边框打印逻辑移除,并重构为独立的CalculateTotalWidth和CenterPadDisplay方法,提高代码复用性和可维护性
1 parent 7417f7a commit a5017fc

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

GameFrameX.Foundation.Options/OptionsDebugger.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public static class OptionsDebugger
2727
/// <param name="options">解析后的选项对象</param>
2828
public static void PrintParsedOptions<T>(T options) where T : class
2929
{
30-
Console.WriteLine("╔══════════════════════════════════════════════════════════════════════╗");
31-
Console.WriteLine("║ Command-line parameter and parsed configuration object information ║");
32-
Console.WriteLine("╚══════════════════════════════════════════════════════════════════════╝");
33-
Console.WriteLine();
34-
3530
try
3631
{
3732
// 使用反射获取所有属性
@@ -155,6 +150,19 @@ public static void PrintParsedOptions<T>(T options) where T : class
155150
}
156151

157152
int maxTableWidth = Math.Max(60, consoleWidth - 1);
153+
154+
// 计算最终表格宽度,用于上方/下方的双线边框和居中标题
155+
int tableWidth = CalculateTotalWidth();
156+
string topDouble = "╔" + new string('═', Math.Max(0, tableWidth - 2)) + "╗";
157+
string bottomDouble = "╚" + new string('═', Math.Max(0, tableWidth - 2)) + "╝";
158+
string headerText = "Command-line parameter and parsed configuration object information";
159+
string centeredHeader = CenterPadDisplay(headerText, Math.Max(0, tableWidth - 2));
160+
161+
Console.WriteLine(topDouble);
162+
Console.WriteLine($"║{centeredHeader}║");
163+
Console.WriteLine(bottomDouble);
164+
Console.WriteLine();
165+
158166
while (CalculateTotalWidth() > maxTableWidth)
159167
{
160168
if (descWidth > minDescWidth)

0 commit comments

Comments
 (0)