Patrik Svensson 450d87f5d3 Add support for fake input in asciicast recordings
* Fixes a bug with `SelectionPrompt` and page size.
* Allow `IAnsiConsoleInput` to return `null`.
2021-05-23 22:22:44 -04:00

25 lines
622 B
C#

using System;
namespace Spectre.Console
{
internal sealed class DefaultInput : IAnsiConsoleInput
{
private readonly Profile _profile;
public DefaultInput(Profile profile)
{
_profile = profile ?? throw new ArgumentNullException(nameof(profile));
}
public ConsoleKeyInfo? ReadKey(bool intercept)
{
if (!_profile.Capabilities.Interactive)
{
throw new InvalidOperationException("Failed to read input in non-interactive mode.");
}
return System.Console.ReadKey(intercept);
}
}
}