Skip to content

Commit 4e00795

Browse files
AdmiringWormgep13
authored andcommitted
(GH-195) Change the grabbing of console width to be in try/catch
1 parent 8d2e11e commit 4e00795

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Source/GitReleaseManager.Cli/Program.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ private static void CreateFiglet(BaseSubOptions options)
112112
+ " \\____|_|\\__|_| \\_\\___|_|\\___|\\__,_|___/\\___|_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_|\n"
113113
+ " |___/\n"
114114
+ "{0,87}\n";
115-
if (Console.WindowWidth > 87)
115+
116+
if (GetConsoleWidth() > 87)
116117
{
117118
Log.Information(longFormat, version);
118119
}
@@ -122,6 +123,28 @@ private static void CreateFiglet(BaseSubOptions options)
122123
}
123124
}
124125

126+
private static int GetConsoleWidth()
127+
{
128+
try
129+
{
130+
return Console.WindowWidth;
131+
}
132+
catch
133+
{
134+
Log.Verbose("Unable to get the width of the console.");
135+
}
136+
137+
try
138+
{
139+
return Console.BufferWidth;
140+
}
141+
catch
142+
{
143+
Log.Verbose("Unable to get the width of the buffer");
144+
return int.MaxValue;
145+
}
146+
}
147+
125148
private static async Task<int> CreateReleaseAsync(CreateSubOptions subOptions)
126149
{
127150
Log.Information("Creating release...");

0 commit comments

Comments
 (0)