diff --git a/README.md b/README.md
index 2ac1f70..2800d44 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,6 @@ AnsiConsole.WriteLine("Hello World!");
AnsiConsole.Reset();
AnsiConsole.WriteLine("Good bye!");
-AnsiConsole.WriteLine();
```
If you want to get a reference to the default `IAnsiConsole`,
diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs
index c322fab..f9d9f76 100644
--- a/src/Sample/Program.cs
+++ b/src/Sample/Program.cs
@@ -1,9 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.InteropServices;
using Spectre.Console;
namespace Sample
@@ -17,7 +12,7 @@ namespace Sample
AnsiConsole.Style = Styles.Underline | Styles.Bold;
AnsiConsole.WriteLine("Hello World!");
AnsiConsole.Reset();
- AnsiConsole.WriteLine($"Capabilities: {AnsiConsole.Capabilities}");
+ AnsiConsole.WriteLine("Capabilities: {0}", AnsiConsole.Capabilities);
AnsiConsole.WriteLine($"Width={AnsiConsole.Width}, Height={AnsiConsole.Height}");
AnsiConsole.WriteLine("Good bye!");
AnsiConsole.WriteLine();
@@ -41,7 +36,7 @@ namespace Sample
console.WriteLine("Hello World!");
console.ResetColors();
console.ResetStyle();
- console.WriteLine($"Capabilities: {console.Capabilities}");
+ console.WriteLine("Capabilities: {0}", AnsiConsole.Capabilities);
console.WriteLine($"Width={AnsiConsole.Width}, Height={AnsiConsole.Height}");
console.WriteLine("Good bye!");
console.WriteLine();
diff --git a/src/Spectre.Console.Tests/AnsiConsoleFixture.cs b/src/Spectre.Console.Tests/AnsiConsoleFixture.cs
index ee0bbd5..70913bc 100644
--- a/src/Spectre.Console.Tests/AnsiConsoleFixture.cs
+++ b/src/Spectre.Console.Tests/AnsiConsoleFixture.cs
@@ -11,13 +11,13 @@ namespace Spectre.Console.Tests
public string Output => _writer.ToString();
- public AnsiConsoleFixture(ColorSystem system)
+ public AnsiConsoleFixture(ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes)
{
_writer = new StringWriter();
Console = AnsiConsole.Create(new AnsiConsoleSettings
{
- Ansi = AnsiSupport.Yes,
+ Ansi = ansi,
ColorSystem = (ColorSystemSupport)system,
Out = _writer,
});
diff --git a/src/Spectre.Console.Tests/AnsiConsoleTests.cs b/src/Spectre.Console.Tests/AnsiConsoleTests.cs
index 2f380ab..edc7aa6 100644
--- a/src/Spectre.Console.Tests/AnsiConsoleTests.cs
+++ b/src/Spectre.Console.Tests/AnsiConsoleTests.cs
@@ -1,3 +1,5 @@
+using System;
+using System.Globalization;
using Shouldly;
using Xunit;
@@ -68,5 +70,351 @@ namespace Spectre.Console.Tests
// Then
fixture.Output.ShouldBe("\u001b[90;47mHello\u001b[0m");
}
+
+ public sealed class Write
+ {
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Int32_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, 32);
+
+ // Then
+ fixture.Output.ShouldBe("32");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_UInt32_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, 32U);
+
+ // Then
+ fixture.Output.ShouldBe("32");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Int64_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, 32L);
+
+ // Then
+ fixture.Output.ShouldBe("32");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_UInt64_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, 32UL);
+
+ // Then
+ fixture.Output.ShouldBe("32");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Single_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, 32.432F);
+
+ // Then
+ fixture.Output.ShouldBe("32.432");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Double_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, (double)32.432);
+
+ // Then
+ fixture.Output.ShouldBe("32.432");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Decimal_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, 32.432M);
+
+ // Then
+ fixture.Output.ShouldBe("32.432");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Boolean_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, true);
+
+ // Then
+ fixture.Output.ShouldBe("True");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Char_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(CultureInfo.InvariantCulture, 'P');
+
+ // Then
+ fixture.Output.ShouldBe("P");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Char_Array_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(
+ CultureInfo.InvariantCulture,
+ new[] { 'P', 'a', 't', 'r', 'i', 'k' });
+
+ // Then
+ fixture.Output.ShouldBe("Patrik");
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Formatted_String_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.Write(
+ CultureInfo.InvariantCulture,
+ "Hello {0}! {1}",
+ "World", 32);
+
+ // Then
+ fixture.Output.ShouldBe("Hello World! 32");
+ }
+ }
+
+ public sealed class WriteLine
+ {
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Int32_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32);
+
+ // Then
+ fixture.Output.ShouldBe("32" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_UInt32_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32U);
+
+ // Then
+ fixture.Output.ShouldBe("32" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Int64_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32L);
+
+ // Then
+ fixture.Output.ShouldBe("32" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_UInt64_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32UL);
+
+ // Then
+ fixture.Output.ShouldBe("32" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Single_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32.432F);
+
+ // Then
+ fixture.Output.ShouldBe("32.432" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Double_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, (double)32.432);
+
+ // Then
+ fixture.Output.ShouldBe("32.432" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Decimal_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32.432M);
+
+ // Then
+ fixture.Output.ShouldBe("32.432" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Boolean_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, true);
+
+ // Then
+ fixture.Output.ShouldBe("True" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Char_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(CultureInfo.InvariantCulture, 'P');
+
+ // Then
+ fixture.Output.ShouldBe("P" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Char_Array_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(
+ CultureInfo.InvariantCulture,
+ new[] { 'P', 'a', 't', 'r', 'i', 'k' });
+
+ // Then
+ fixture.Output.ShouldBe("Patrik" + Environment.NewLine);
+ }
+
+ [Theory]
+ [InlineData(AnsiSupport.Yes)]
+ [InlineData(AnsiSupport.No)]
+ public void Should_Write_Formatted_String_With_Format_Provider(AnsiSupport ansi)
+ {
+ // Given
+ var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi);
+
+ // When
+ fixture.Console.WriteLine(
+ CultureInfo.InvariantCulture,
+ "Hello {0}! {1}",
+ "World", 32);
+
+ // Then
+ fixture.Output.ShouldBe("Hello World! 32" + Environment.NewLine);
+ }
+ }
}
}
diff --git a/src/Spectre.Console/AnsiConsole.Write.cs b/src/Spectre.Console/AnsiConsole.Write.cs
new file mode 100644
index 0000000..aa9cdb6
--- /dev/null
+++ b/src/Spectre.Console/AnsiConsole.Write.cs
@@ -0,0 +1,245 @@
+using System;
+using System.Globalization;
+
+namespace Spectre.Console
+{
+ ///
+ /// A console capable of writing ANSI escape sequences.
+ ///
+ public static partial class AnsiConsole
+ {
+ ///
+ /// Writes the specified string value to the console.
+ ///
+ /// The value to write.
+ public static void Write(string value)
+ {
+ Console.Write(value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// signed integer value to the console.
+ ///
+ /// The value to write.
+ public static void Write(int value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// signed integer value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, int value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// unsigned integer value to the console.
+ ///
+ /// The value to write.
+ public static void Write(uint value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// unsigned integer value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, uint value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// signed integer value to the console.
+ ///
+ /// The value to write.
+ public static void Write(long value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// signed integer value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, long value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// unsigned integer value to the console.
+ ///
+ /// The value to write.
+ public static void Write(ulong value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// unsigned integer value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, ulong value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision
+ /// floating-point value to the console.
+ ///
+ /// The value to write.
+ public static void Write(float value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision
+ /// floating-point value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, float value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision
+ /// floating-point value to the console.
+ ///
+ /// The value to write.
+ public static void Write(double value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision
+ /// floating-point value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, double value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value, to the console.
+ ///
+ /// The value to write.
+ public static void Write(decimal value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, decimal value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value to the console.
+ ///
+ /// The value to write.
+ public static void Write(bool value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, bool value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified Unicode character to the console.
+ ///
+ /// The value to write.
+ public static void Write(char value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified Unicode character to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, char value)
+ {
+ Console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters to the console.
+ ///
+ /// The value to write.
+ public static void Write(char[] value)
+ {
+ Console.Write(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(IFormatProvider provider, char[] value)
+ {
+ Console.Write(provider, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// to the console using the specified format information.
+ ///
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void Write(string format, params object[] args)
+ {
+ Console.Write(CultureInfo.CurrentCulture, format, args);
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// to the console using the specified format information.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void Write(IFormatProvider provider, string format, params object[] args)
+ {
+ Console.Write(string.Format(provider, format, args));
+ }
+ }
+}
diff --git a/src/Spectre.Console/AnsiConsole.WriteLine.cs b/src/Spectre.Console/AnsiConsole.WriteLine.cs
new file mode 100644
index 0000000..a00f183
--- /dev/null
+++ b/src/Spectre.Console/AnsiConsole.WriteLine.cs
@@ -0,0 +1,263 @@
+using System;
+using System.Globalization;
+
+namespace Spectre.Console
+{
+ ///
+ /// A console capable of writing ANSI escape sequences.
+ ///
+ public static partial class AnsiConsole
+ {
+ ///
+ /// Writes an empty line to the console.
+ ///
+ public static void WriteLine()
+ {
+ Console.WriteLine();
+ }
+
+ ///
+ /// Writes the specified string value, followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(string value)
+ {
+ Console.WriteLine(value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(int value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, int value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(uint value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, uint value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(long value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, long value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(ulong value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, ulong value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(float value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, float value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(double value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, double value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(decimal value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, decimal value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(bool value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, bool value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified Unicode character, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(char value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified Unicode character, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, char value)
+ {
+ Console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// The value to write.
+ public static void WriteLine(char[] value)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(IFormatProvider provider, char[] value)
+ {
+ Console.WriteLine(provider, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// followed by the current line terminator, to the console
+ /// using the specified format information.
+ ///
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void WriteLine(string format, params object[] args)
+ {
+ Console.WriteLine(CultureInfo.CurrentCulture, format, args);
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// followed by the current line terminator, to the console
+ /// using the specified format information.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void WriteLine(IFormatProvider provider, string format, params object[] args)
+ {
+ Console.WriteLine(string.Format(provider, format, args));
+ }
+ }
+}
diff --git a/src/Spectre.Console/AnsiConsole.cs b/src/Spectre.Console/AnsiConsole.cs
index cb5ecd5..682effa 100644
--- a/src/Spectre.Console/AnsiConsole.cs
+++ b/src/Spectre.Console/AnsiConsole.cs
@@ -6,7 +6,7 @@ namespace Spectre.Console
///
/// A console capable of writing ANSI escape sequences.
///
- public static class AnsiConsole
+ public static partial class AnsiConsole
{
private static readonly Lazy _console = new Lazy(() =>
{
@@ -105,31 +105,5 @@ namespace Spectre.Console
{
Console.ResetColors();
}
-
- ///
- /// Writes the content to the console.
- ///
- /// The content to write.
- public static void Write(string content)
- {
- Console.Write(content);
- }
-
- ///
- /// Writes an empty line to the console.
- ///
- public static void WriteLine()
- {
- Console.WriteLine();
- }
-
- ///
- /// Writes a line to the console.
- ///
- /// The content to write.
- public static void WriteLine(string content)
- {
- Console.WriteLine(content);
- }
}
}
diff --git a/src/Spectre.Console/ConsoleExtensions.Write.cs b/src/Spectre.Console/ConsoleExtensions.Write.cs
new file mode 100644
index 0000000..30f2e28
--- /dev/null
+++ b/src/Spectre.Console/ConsoleExtensions.Write.cs
@@ -0,0 +1,339 @@
+using System;
+using System.Globalization;
+
+namespace Spectre.Console
+{
+ ///
+ /// Contains extension methods for .
+ ///
+ public static partial class ConsoleExtensions
+ {
+ ///
+ /// Writes the specified string value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, string value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ if (value != null)
+ {
+ console.Write(value);
+ }
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// signed integer value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, int value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// signed integer value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, int value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// unsigned integer value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, uint value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit
+ /// unsigned integer value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, uint value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// signed integer value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, long value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// signed integer value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, long value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// unsigned integer value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, ulong value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit
+ /// unsigned integer value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, ulong value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision
+ /// floating-point value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, float value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision
+ /// floating-point value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, float value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision
+ /// floating-point value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, double value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision
+ /// floating-point value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, double value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.Write(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, decimal value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, decimal value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ Write(console, value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, bool value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, bool value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ Write(console, value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified Unicode character to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, char value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified Unicode character to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, char value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ Write(console, value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, char[] value)
+ {
+ Write(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, char[] value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ if (value is null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ for (var index = 0; index < value.Length; index++)
+ {
+ console.Write(value[index].ToString(provider));
+ }
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// to the console using the specified format information.
+ ///
+ /// The console to write to.
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void Write(this IAnsiConsole console, string format, params object[] args)
+ {
+ Write(console, CultureInfo.CurrentCulture, format, args);
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// to the console using the specified format information.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void Write(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ Write(console, string.Format(provider, format, args));
+ }
+ }
+}
diff --git a/src/Spectre.Console/ConsoleExtensions.WriteLine.cs b/src/Spectre.Console/ConsoleExtensions.WriteLine.cs
new file mode 100644
index 0000000..731b4fa
--- /dev/null
+++ b/src/Spectre.Console/ConsoleExtensions.WriteLine.cs
@@ -0,0 +1,368 @@
+using System;
+using System.Globalization;
+
+namespace Spectre.Console
+{
+ ///
+ /// Contains extension methods for .
+ ///
+ public static partial class ConsoleExtensions
+ {
+ ///
+ /// Writes an empty line to the console.
+ ///
+ /// The console to write to.
+ public static void WriteLine(this IAnsiConsole console)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.Write(Environment.NewLine);
+ }
+
+ ///
+ /// Writes the specified string value, followed by the
+ /// current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, string value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ if (value != null)
+ {
+ console.Write(value);
+ }
+
+ console.WriteLine();
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, int value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, int value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, uint value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 32-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, uint value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, long value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit signed integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, long value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, ulong value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified 64-bit unsigned integer value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, ulong value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, float value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified single-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, float value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, double value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified double-precision floating-point
+ /// value, followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, double value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ console.WriteLine(value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, decimal value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified decimal value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, decimal value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ WriteLine(console, value.ToString(provider));
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, bool value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the text representation of the specified boolean value,
+ /// followed by the current line terminator, to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, bool value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ WriteLine(console, value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified Unicode character, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, char value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified Unicode character, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, char value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ WriteLine(console, value.ToString(provider));
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// The console to write to.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, char[] value)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, value);
+ }
+
+ ///
+ /// Writes the specified array of Unicode characters, followed by the current
+ /// line terminator, value to the console.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// The value to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, char[] value)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ if (value is null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ for (var index = 0; index < value.Length; index++)
+ {
+ console.Write(value[index].ToString(provider));
+ }
+
+ console.WriteLine();
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// followed by the current line terminator, to the console
+ /// using the specified format information.
+ ///
+ /// The console to write to.
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void WriteLine(this IAnsiConsole console, string format, params object[] args)
+ {
+ WriteLine(console, CultureInfo.CurrentCulture, format, args);
+ }
+
+ ///
+ /// Writes the text representation of the specified array of objects,
+ /// followed by the current line terminator, to the console
+ /// using the specified format information.
+ ///
+ /// The console to write to.
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string.
+ /// An array of objects to write.
+ public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
+ {
+ if (console is null)
+ {
+ throw new ArgumentNullException(nameof(console));
+ }
+
+ WriteLine(console, string.Format(provider, format, args));
+ }
+ }
+}
diff --git a/src/Spectre.Console/ConsoleExtensions.cs b/src/Spectre.Console/ConsoleExtensions.cs
index 9e9529a..082f40c 100644
--- a/src/Spectre.Console/ConsoleExtensions.cs
+++ b/src/Spectre.Console/ConsoleExtensions.cs
@@ -5,7 +5,7 @@ namespace Spectre.Console
///
/// Contains extension methods for .
///
- public static class ConsoleExtensions
+ public static partial class ConsoleExtensions
{
///
/// Resets both colors and style for the console.
@@ -50,34 +50,5 @@ namespace Spectre.Console
console.Foreground = Color.Default;
console.Background = Color.Default;
}
-
- ///
- /// Writes an empty line to the console.
- ///
- /// The console to write to.
- public static void WriteLine(this IAnsiConsole console)
- {
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
-
- console.WriteLine(null);
- }
-
- ///
- /// Writes a line to the console.
- ///
- /// The console to write to.
- /// The content to write.
- public static void WriteLine(this IAnsiConsole console, string content)
- {
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
-
- console.WriteLine(content);
- }
}
}
diff --git a/src/Spectre.Console/IAnsiConsole.cs b/src/Spectre.Console/IAnsiConsole.cs
index 6e6fd31..d113c81 100644
--- a/src/Spectre.Console/IAnsiConsole.cs
+++ b/src/Spectre.Console/IAnsiConsole.cs
@@ -40,13 +40,5 @@ namespace Spectre.Console
///
/// The string to write.
void Write(string text);
-
- ///
- /// Writes a string followed by a line terminator to the console.
- ///
- ///
- /// The string to write. If value is null, only the line terminator is written.
- ///
- void WriteLine(string text);
}
}
diff --git a/src/Spectre.Console/Internal/Rendering/AnsiConsoleRenderer.cs b/src/Spectre.Console/Internal/Rendering/AnsiConsoleRenderer.cs
index 0c9a11d..3c5421d 100644
--- a/src/Spectre.Console/Internal/Rendering/AnsiConsoleRenderer.cs
+++ b/src/Spectre.Console/Internal/Rendering/AnsiConsoleRenderer.cs
@@ -78,23 +78,5 @@ namespace Spectre.Console.Internal
Foreground,
Background));
}
-
- public void WriteLine(string text)
- {
- if (text == null)
- {
- _out.WriteLine();
- }
- else
- {
- _out.WriteLine(
- AnsiBuilder.GetAnsi(
- _system,
- text,
- Style,
- Foreground,
- Background));
- }
- }
}
}
\ No newline at end of file
diff --git a/src/Spectre.Console/Internal/Rendering/FallbackConsoleRenderer.cs b/src/Spectre.Console/Internal/Rendering/FallbackConsoleRenderer.cs
index d001e00..0d845cb 100644
--- a/src/Spectre.Console/Internal/Rendering/FallbackConsoleRenderer.cs
+++ b/src/Spectre.Console/Internal/Rendering/FallbackConsoleRenderer.cs
@@ -105,17 +105,5 @@ namespace Spectre.Console.Internal
{
_out.Write(text);
}
-
- public void WriteLine(string text)
- {
- if (text == null)
- {
- _out.WriteLine();
- }
- else
- {
- _out.WriteLine(text);
- }
- }
}
}
diff --git a/src/Spectre.Console/Spectre.Console.csproj b/src/Spectre.Console/Spectre.Console.csproj
index 3ba142c..f2c2f1b 100644
--- a/src/Spectre.Console/Spectre.Console.csproj
+++ b/src/Spectre.Console/Spectre.Console.csproj
@@ -12,6 +12,12 @@
Color.cs
+
+ AnsiConsole.cs
+
+
+ ConsoleExtensions.cs
+