mirror of
https://github.com/jcreek/YouTubeChannelDownloader.git
synced 2026-07-13 11:13:46 +00:00
feat(*): Add inline progress utility
This is a customised version of the one used in the YouTubeExplode converter windows app, that now only prints when there's a new number, in order to get it to work better using docker logs to monitor it rather than an actual console.
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YouTubeChannelDownloader.Utilities
|
||||||
|
{
|
||||||
|
internal class InlineProgress : IProgress<double>, IDisposable
|
||||||
|
{
|
||||||
|
private readonly int _posX;
|
||||||
|
private readonly int _posY;
|
||||||
|
private string lastProgressPrint = string.Empty;
|
||||||
|
|
||||||
|
public InlineProgress()
|
||||||
|
{
|
||||||
|
_posX = Console.CursorLeft;
|
||||||
|
_posY = Console.CursorTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Report(double progress)
|
||||||
|
{
|
||||||
|
string currentProgress = $"{progress:P1}";
|
||||||
|
if (currentProgress != lastProgressPrint)
|
||||||
|
{
|
||||||
|
Console.SetCursorPosition(_posX, _posY);
|
||||||
|
Console.WriteLine(currentProgress);
|
||||||
|
|
||||||
|
lastProgressPrint = currentProgress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Console.SetCursorPosition(_posX, _posY);
|
||||||
|
Console.WriteLine("Completed ✓");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user