using System;
using System.Threading.Tasks;
using Spectre.Console.Internal;
namespace Spectre.Console
{
///
/// Represents a status display.
///
public sealed class Status
{
private readonly IAnsiConsole _console;
///
/// Gets or sets the spinner.
///
public Spinner? Spinner { get; set; }
///
/// Gets or sets the spinner style.
///
public Style? SpinnerStyle { get; set; } = new Style(foreground: Color.Yellow);
///
/// Gets or sets a value indicating whether or not status
/// should auto refresh. Defaults to true.
///
public bool AutoRefresh { get; set; } = true;
///
/// Initializes a new instance of the class.
///
/// The console.
public Status(IAnsiConsole console)
{
_console = console ?? throw new ArgumentNullException(nameof(console));
}
///
/// Starts a new status display.
///
/// The status to display.
/// he action to execute.
public void Start(string status, Action action)
{
var task = StartAsync(status, ctx =>
{
action(ctx);
return Task.CompletedTask;
});
task.GetAwaiter().GetResult();
}
///
/// Starts a new status display.
///
/// The status to display.
/// he action to execute.
/// A representing the asynchronous operation.
public async Task StartAsync(string status, Func action)
{
if (action is null)
{
throw new ArgumentNullException(nameof(action));
}
_ = await StartAsync