using System;
namespace Spectre.Console
{
///
/// Contains extension methods for .
///
public static partial class AnsiConsoleExtensions
{
///
/// Creates a recorder for the specified console.
///
/// The console to record.
/// A recorder for the specified console.
public static Recorder CreateRecorder(this IAnsiConsole console)
{
return new Recorder(console);
}
///
/// Clears the console.
///
/// The console to clear.
public static void Clear(this IAnsiConsole console)
{
if (console is null)
{
throw new ArgumentNullException(nameof(console));
}
console.Clear(true);
}
///
/// Writes the specified string value to the console.
///
/// The console to write to.
/// The text to write.
public static void Write(this IAnsiConsole console, string text)
{
if (console is null)
{
throw new ArgumentNullException(nameof(console));
}
console.Write(new Text(text, Style.Plain));
}
///
/// Writes the specified string value to the console.
///
/// The console to write to.
/// The text to write.
/// The text style or if .
public static void Write(this IAnsiConsole console, string text, Style? style)
{
if (console is null)
{
throw new ArgumentNullException(nameof(console));
}
console.Write(new Text(text, style));
}
///
/// 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(Text.NewLine);
}
///
/// Writes the specified string value, followed by the current line terminator, to the console.
///
/// The console to write to.
/// The text to write.
public static void WriteLine(this IAnsiConsole console, string text)
{
WriteLine(console, text, Style.Plain);
}
///
/// Writes the specified string value, followed by the current line terminator, to the console.
///
/// The console to write to.
/// The text to write.
/// The text style or if .
public static void WriteLine(this IAnsiConsole console, string text, Style? style)
{
if (console is null)
{
throw new ArgumentNullException(nameof(console));
}
if (text is null)
{
throw new ArgumentNullException(nameof(text));
}
console.Write(text + Environment.NewLine, style);
}
}
}