Add progress reporting to CLI

Closes #143
This commit is contained in:
Alexey Golub
2019-03-03 19:59:23 +02:00
parent 492003c75a
commit e493357a9f
4 changed files with 81 additions and 50 deletions

View File

@@ -0,0 +1,28 @@
using System;
namespace DiscordChatExporter.Cli.Internal
{
internal class InlineProgress : IProgress<double>, IDisposable
{
private readonly int _posX;
private readonly int _posY;
public InlineProgress()
{
_posX = Console.CursorLeft;
_posY = Console.CursorTop;
}
public void Report(double progress)
{
Console.SetCursorPosition(_posX, _posY);
Console.WriteLine($"{progress:P1}");
}
public void Dispose()
{
Console.SetCursorPosition(_posX, _posY);
Console.WriteLine("Completed ✓");
}
}
}