Index: Migration/Console/src/Migration.Console/ConsoleHelper.cs
===================================================================
diff -u -rac9fc776779eb7f111ca7d9911d4684d47818891 -r0930763dbd895350070e8075dc9d7ba1bd89cf0f
--- Migration/Console/src/Migration.Console/ConsoleHelper.cs (.../ConsoleHelper.cs) (revision ac9fc776779eb7f111ca7d9911d4684d47818891)
+++ Migration/Console/src/Migration.Console/ConsoleHelper.cs (.../ConsoleHelper.cs) (revision 0930763dbd895350070e8075dc9d7ba1bd89cf0f)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.IO;
using SystemConsole = System.Console;
@@ -53,5 +54,63 @@
SystemConsole.WriteLine(format, args);
SystemConsole.ResetColor();
}
+
+ ///
+ /// Writes as a description text to the .
+ ///
+ /// A composite format string.
+ /// An array of objects to write using .
+ /// Thrown when any of the input parameters is null.
+ /// Thrown when an I/O error occurred.
+ /// Thrown when the format specification in is invalid.
+ ///
+ public static void WriteCommandDescriptionLine(string format, params object[] args)
+ {
+
+ const int paddingLeft = 10;
+ const int paddingRight = 1;
+ WriteLineWithPadding(format, args, paddingLeft, paddingRight);
+ SystemConsole.WriteLine();
+ }
+
+ private static void WriteLineWithPadding(string format, object[] args, int paddingLeft, int paddingRight)
+ {
+ if (format == null)
+ {
+ throw new ArgumentNullException(nameof(format));
+ }
+ if (args == null)
+ {
+ throw new ArgumentNullException(nameof(args));
+ }
+ var windowWidth = GetWindowWidth() - paddingRight;
+
+ int bufferSize = windowWidth - paddingLeft;
+ var paddingString = new string(' ', paddingLeft);
+ foreach (var line in format.SplitByLength(bufferSize))
+ {
+ SystemConsole.WriteLine($@"{paddingString}{line.TrimStart()}", args);
+ }
+ }
+
+ private static int GetWindowWidth()
+ {
+ try
+ {
+ return SystemConsole.WindowWidth;
+ }
+ catch (IOException)
+ {
+ return 80;
+ }
+ }
+
+ private static IEnumerable SplitByLength(this string str, int maxLength)
+ {
+ for (int index = 0; index < str.Length; index += maxLength)
+ {
+ yield return str.Substring(index, Math.Min(maxLength, str.Length - index));
+ }
+ }
}
}
\ No newline at end of file